1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
dedylja [7]
3 years ago
8

Write the definition of a method printAttitude, which has an int parameter and returns nothing. The method prints a message to s

tandard output depending on the value of its parameter. If the parameter equals 1, the method prints disagree If the parameter equals 2, the method prints no opinion If the parameter equals 3, the method prints agree In the case of other values, the method does nothing. Each message is printed on a line by itself.
Computers and Technology
1 answer:
Jlenok [28]3 years ago
6 0

Answer:

public void printAttitude(int n){

   if(n == 1){

       System.out.println("disagree");

   }

  else if(n == 2){

      System.out.println("no option");

  }

  else if(n == 3){

      System.out.println("agree");

  }

  else {

  }

}

Explanation:

The above code has been written using Java syntax. The first line denotes the method header which contains the access modifier(public), followed by the return type(void), followed by the name of the method(printAttitude). The method name is followed by a pair of parentheses in which the parameter to the method is written - in this case - an int parameter, n.

Note: When a method does not return a value. It has a return type of void as shown on the first line of the code.

In the method body, a nested if...else statement is written to test for the value of the parameter. If the parameter value of n is 1, the string "disagree" is printed to the console. Else if the parameter value of n is 2, the string "no option" is printed to the console. if the parameter value of n is 3, the string "agree" is printed to the console. For other values of n, nothing is printed. This is shown in the body of the else statement.

Hope this helps!

You might be interested in
___________ poses the greatest risk to workers because it is more common and more easily transmitted than other bloodborne disea
Evgesh-ka [11]

Answer: Hepatitis

Explanation: According to the center for disease control and prevention (CDC) HIV, hepatitis B and Hepatitis C are the most common bloodborne pathogens which workers are more susceptible to contract. According to CDC's the estimated risk of an HIV infection is 0.3 percent, 1 from 300 people. Hepatitis B has from 6 to 30 percent causing serious liver damage. And Hepatitis C has a risk between 2 and 4 percent

3 0
2 years ago
Why do computers make mistakes​
zysi [14]

Answer:

because maybe it is have a virus...

7 0
3 years ago
Read 2 more answers
What is meant by check digit
Strike441 [17]

Answer:it is the last number in a general digit

Explanation:

6 0
3 years ago
What is sodaglass in glass technology ​
IRISSAK [1]

also called lime, silica glass, is the most prevalent type of glass, used for windowpanes and glass containers (bottles and jars) for beverages, food, and some commodity items. Glass bake ware is often made of borosilicate glass.

8 0
4 years ago
!!!URGENT!!!
zvonat [6]
A. Integers. Integers have to do with positive or negative whole numbers without decimals, so like with apples in a basket you would have 5 apples, not 5.67 apples. Whereas floating numbers has to do with decimals where it is basically saying the decimal can float. Strings are quite confusing but basically this is a string 1.5.1, and you would not have 1.5.1 of an apple. A Boolean is have to do with the truth values true and false and is normally denoted 1 and 0. Hope this helps!
3 0
4 years ago
Other questions:
  • help users calculate their car miles per gallon. write a program to allow a user to enter the number of miles driven and the num
    15·1 answer
  • In public-key encryption, the two keys–one for coding and one for decoding–are known as ________.
    6·1 answer
  • Digital subscriber lines: a. are very-high-speed data lines typically leased from long-distance telephone companies. b. operate
    5·1 answer
  • Which of these statements most accurately describes cookies?They have the capability to execute malicious software.Each cookie f
    12·1 answer
  • Which type of financial institution typically has membership requirements?
    14·1 answer
  • Find the complete predicate in the sentence below.
    6·1 answer
  • SOMEONE PLEASE HELP ME OUT WITH THIS!!!!!!
    12·2 answers
  • What are some benefits that each computer system being used?
    12·2 answers
  • True or false?
    6·1 answer
  • List three variables that could be used in creating a model that determines the best day to plant corn in a given location. 30 p
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!