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
Tim is in charge of the upcoming interschool baketball tournamnent. He wants to arrange all of the teams and their members in al
zalisa [80]
I think the answer is C.
7 0
3 years ago
You are finally at the stage of the software life cycle where you begin programming. What is this stage called?
nataly862011 [7]
You are finally at the stage of the software life cycle where you begin programming. What is this stage called?

development

5 0
2 years ago
What do you mean by an algorithm?<br>​
Over [174]
A program that can be used in many scenarios
8 0
2 years ago
What is the Digital Living Network Alliance ?
Sedaia [141]

The digital living alliance network is a set of guidelines to share digital media among wired and wireless multimedia devices.

<h3>What is the digital living alliance network?</h3>

The Digital Living Network Alliance is a trade association that establishes rules and practices for home network equipment, incorporating computers, smartphones, etc.

It is a set of guidelines to share digital media among wired and wireless multimedia devices.

Learn more about digital on:

brainly.com/question/23749502

#SPJ12

8 0
2 years ago
Read 2 more answers
Wendy wants to learn how to write a computer program that can get the dimensions of a rectangle from the user and then tell the
otez555 [7]

Answer:

algorithms for finding the area

Explanation:

you need algorithms to find out any computer input information.

4 0
3 years ago
Read 2 more answers
Other questions:
  • Suppose you're trying to remove the clamp from a ground strap that's connected to a battery. The clamp won't come loose. Which o
    14·2 answers
  • Need help writing a program that reads a string if the option "E" (enter a string) is chosen, and checks if parentheses (), brac
    14·1 answer
  • Select the correct answer from each drop-down menu. Kristian is a cybersecurity professional. She is writing a book called The D
    7·2 answers
  • Write a program which populates an array with integer values read from a file. We do not know how many integers are in the file,
    8·1 answer
  • It's fill the gap homework
    7·1 answer
  • Give an essay on a way I can be a better person. If not correct I will refund. Best answer gets brainiest. Detailed, 5 sentience
    10·2 answers
  • When adjusting the aperture, an F-stop of F32 lets in more light then a setting of F8
    10·1 answer
  • it just said i was blocked from brainly for a sec i was like- dang- then i logged in again then it was back to normal uHhHh can
    8·2 answers
  • Assume you have a button control named btndisplaylist. Which is the default name for an event procedure that will be executed wh
    14·1 answer
  • What can a human till do better and fater than any Machine Learning (ML) olution?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!