answer.
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
Svetradugi [14.3K]
1 year ago
14

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

to standard output depending on the value of its parameter. If the parameter equals 1, the function prints disagree If the parameter equals 2, the function prints no opinion If the parameter equals 3, the function prints agree In the case of other values, the function does nothing.
Computers and Technology
1 answer:
Oksana_A [137]1 year ago
4 0

Answer:

The function definition, in cpp, for the function printAttitude is given below.

void printAttitude(int n)

{

switch(n)

{

case 1: cout<<"disagree"<<endl; break;

case 2: cout<<"no opinion"<<endl; break;

case 3: cout<<"agree"<<endl; break;

default: break;

}

}

Explanation:

As seen, the method takes an integer parameter.

The method does not returns any value hence, return type is void.

The message is displayed to the console using switch statement which executes on the integer parameter, n.

The values for which output needs to be displayed are taken in cases.

The values for which no output needs to be displayed, is taken in default case.

Every case ends with break statement so that the program execution can be terminated.

This method can be used inside a program as shown.  

PROGRAM

#include <iostream>

using namespace std;

void printAttitude(int n)

{

switch(n)

{

case 1: cout<<"disagree"<<endl; break;

case 2: cout<<"no opinion"<<endl; break;

case 3: cout<<"agree"<<endl; break;

default: break;

}

}

int main() {

// variables to hold respective value

int n;

// user input taken for n

cout<<"Enter any number: ";

cin>>n;

// calling the function taking integer parameter  

printAttitude(n);

return 0;

}

OUTPUT

Enter any number: 11

1. The user input is taken for the integer parameter.

2. Inside main(), the method, printAttitude(), is then called and the user input is passed as a parameter.

3. Since the user entered value is 11 which does not satisfies any of the values in the cases, the default case is entered which does nothing and executes the break statement.

4. Hence, the program displays nothing for the value of 11.

5. When the user enters value 3, the case statement is executed since 3 satisfies one of the case values.

6. The program output for the user input of 3 is as shown below.

OUTPUT

Enter any number: 3

agree

The program ends with return statement.

You might be interested in
Please answer this a due tomorrow!!!
dem82 [27]

Answer:  

4-Well first of all for the "VR" problem it could be a problem, because people could forget about there actual life and not be able to much of anything when needed.

1-the first one you are going to have to answer.

2-If you have different files then you aren't stumbling through multiple different links and could have trouble with finding what is needed.

3-the third one you are going to have to answer.

5-If I were you I would help them the best way you could so they can actually know how to do their job.

5 0
1 year ago
XYZ Corp.’s facilities in Nashua, New Hampshire, are two office buildings 400 feet apart, each with its own LAN. To connect the
damaskus [11]

Answer:

a: Twisted pair won't span a 400-foot distance.

Explanation:

The maximum distance that twisted pair cables can support without attenuation is 100 meters which is approximately 328 feet and the two office buildings are 400 feet apart, so it is useless to install a twisted pair cable for such a large distance. A much better option would be to install optic fiber. Though it is a bit expensive but it is the best option in this case.

Hence option (a) is the correct reason for installing an optic fiber cable rather than a twisted pair cable.

6 0
1 year ago
Write a method for the Customer class that that will return a string representing a bill notice when passed a double value repre
Nesterboy [21]

Answer:

Following are the method definition to this question:

public String notice_bill(double amount) //defining method

{

return this.name+", account number "+this.currAccNum+", please pay $"+amt;  //return value.

}

Explanation:

In the given question some information is missing, that is example So, method definition to this question can be described as follows:

  • In the above method definition a string method "notice_bill" is declared, which accepts a double value in its parameter, that is "amount".
  • Inside the method, this keyword is used, that hold values and return its value as a message.  
5 0
1 year ago
Suppose your name was George Gershwin. Write a complete program that would print your last name, followed by a comma, followed b
NNADVOKAT [17]

Answer:

I will write the code in C++ and JAVA      

Explanation:

<h2>JAVA CODE</h2>

public class Main

{ public static void main(String[] args) {

       // displays Gershwin,George

     System.out.println("Gershwin,George"); }  }

<h2>C++ Code:</h2>

#include <iostream>

using namespace std;  

int main()

{  cout<<"Gershwin,George"; }    

// displays last name Gershwin followed by , followed by first name George

//displays Gershwin,George as output.

6 0
2 years ago
Read 2 more answers
In the Budget Details sheet, if you wish to autofill with the formula, you must use a ______ reference for the LY Spend Total ce
ahrayia [7]

Answer:

The answer is A.Absolute reference.

Explanation:

Absolute reference is a cell reference whose location remains constant when the formula is copied.

8 0
2 years ago
Other questions:
  • your monthly living expenses are $1500 on an income of $1,650 per month. your goal is to have an emergency fund of 4 times your
    5·1 answer
  • Which presenter would most likely benefit from a custom slide show?
    10·2 answers
  • A class car and its subclass bmw each have a method run(), which was written by the developer as part of the class definition. i
    10·1 answer
  • Jane's organization recently experienced a security incident that occurred when malware set to trigger on the chief executive of
    13·1 answer
  • Given the plaintext {0F0E0D0C0B0A09080706050403020100} and the key {02020202020202020202020202020202}: a. Show the original cont
    11·1 answer
  • Write a flowchart and C code for a program that does the following: Within main(), it asks for the user's annual income. Within
    12·1 answer
  • 2. BIOS is contained in ROM and not in RAM. Can you guess why?​
    15·1 answer
  • Write a function named shout. The function should accept a string argument and display it in uppercase with an exclamation mark
    6·1 answer
  • The code below assigns the 5th letter of each word in food to the new list fifth. However, the code currently produces errors. I
    11·1 answer
  • Doug grew up on a large farm in southwest Wisconsin. As a college graduation gift, Doug’s father gave him several hundred acres
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!