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
Zepler [3.9K]
2 years ago
10

Create the Following Menu in a loop so the menu will continually show until the user chooses to exit.AddMultiplyExitAdd a value

returning function to menu option 1 and menu option 2. This means that you will create two functions: an add function and a multiply function. The functions will receive two doubles and return a double. The following is code I have written to complete this assignment. When entering option 3 after entering option 1 or 2, it does not exit from the program. Also, the menu is appended instead of deleting everything and displaying the original menu.#include #include #include using namespace std;int options ();int option1 ();int option2 ();int option3 ();double addition (double num1, double num2);double multiplication (double num1, double num2);int main(){ int option = 0; cout << "1. Add" << endl; cout << "2. Multiply" << endl; cout << "3. Exit" << endl; cout << "Enter option 1 for addition, option 2 for multiplication, or option 3 to exit" "\nEnter an option: "; cin >> option; switch (option) { case 1:option1; int option1 ();{ double num1 = 0; double num2 = 0;// void int key = 0; cout << "\n Enter a number: "; cin >> num1; cout<< "\n Enter a second number: "; cin >> num2; double sum = addition(num1, num2); cout << "\n Sum is: " << sum <> key; system("cls");} break; case 2: option2; int option2 ();{ double num1 = 0; double num2 = 0;cout << "\n Enter a number:";cin >> num1;cout << "\n Enter a second number: ";cin >> num2;double product = multiplication(num1, num2); cout << "\n Product is: " << product << endl;system("cls");} break; case 3: option3; int option3(); {return 0;} break; default: cout << "\n Invalid number entered: ";}////do {main();}//while (option < 3);}double addition(double num1, double num2){ return num1 + num2;}double multiplication(double num1, double num2){ return num1*num2;}
Computers and Technology
1 answer:
ycow [4]2 years ago
4 0

Answer:

I have added the code again with the mistakes are corrected please see the comments in code. You have mistake in while loop condition.

#include <iostream>

#include <iomanip>

#include <cmath>

using namespace std;

int options ();

int option1 ();

int option2 ();

int option3 ();

double addition (double num1, double num2);

double multiplication (double num1, double num2);

int main()

{  

jump:

int option = 0;  

cout << "1. Add" << endl;

cout << "2. Multiply" << endl;

cout << "3. Exit" << endl;

 cout << "Enter option 1 for addition, option 2 for multiplication, or option 3 to exit" "Enter an option: ";

  cin >> option;

   switch (option)  

{  

case 1:option1;  

int option1 ();

{  

double num1 = 0;  

double num2 = 0;

// void int key = 0;  

cout << " Enter a number: ";  

cin >> num1;  

cout<< " Enter a second number: ";  

cin >> num2;  

double sum = addition(num1, num2);  

cout << " Sum is: " << sum <<endl;

 } break;  

 case 2: option2;  

 int option2 ();

 {  

 double num1 = 0;  

 double num2 = 0;

 cout << " Enter a number:";

 cin >> num1;

 cout << " Enter a second number: ";

 cin >> num2;

 double product = multiplication(num1, num2);

  cout << " Product is: " << product << endl;

  //system("cls");

  }  

  break;

   case 3: option3;  

   int option3();

    {

 return 0;

 }  

 break;  

 default: cout << " Invalid number entered: ";

 }

 //do {main();}

 //while (option < 3); //you have mistake in this loop please have a look

 while (option<3)

 {

  goto jump;

 }

 

 }

 double addition(double num1, double num2)

 {

  return num1 + num2;

  }

 double multiplication(double num1, double num2)

 {

  return num1*num2;

  }

Explanation:

You can also do this by using goto statement in switch case and menu will be repeated until the user not select to exit and now it will work with the loop as well.

I hope it will help you!

You might be interested in
What is likely to happen to the economy when there’s too much money or credit circulating?
Svetlanka [38]
It depends on HOW much money is circulating. If governments just print money with nothing to back it, hyperinflation occurs. If there's a bit too much money and credit, inflation happens. Generally, 3% inflation is considered normal and a healthy amount by economists.
5 0
3 years ago
What frequency band is used by bluetooth, 802.11b, and 802.11g?
bagirrra123 [75]
802.11 is a Wi-Fi standard, not a frequency, both of those operate at 2.4 GHz. Bluetooth operates at frequencies between 2402 and 2480 MHz, or 2400 and 2483.5 MHz. 
4 0
3 years ago
Which cell address indicates the intersection of the first row and the first column in worksheet?
Rzqust [24]

Answer:

A. A1

Explanation:

Worksheet's Columns are named with Alphabets. i.e. A,B,C,D,E....

And Worksheet's rows are named with numbers. i.e. 1,2,3,4,5....

So the intersection of first row number as "1" and First Column name as "A" is A1 as worksheet displays column name first and then row number.

8 0
3 years ago
Read 2 more answers
* 8) Embedded operating systems are specialized software meant only to manage the
Ede4ka [16]

Answer:

True

Explanation:

Embedded operating systems are operating systems which supports hardware which is not a computer and allows the hardware to perform its task.

An example of a device with an embedded operating system is an SD card. The operating system on the card allows the card to be readable by the computer which its is plugged to.

Other examples of hardware with embedded systems are traffic lights, digital televisions, ATMs, point of sale (POS) and digital cameras.

3 0
2 years ago
The design strategy that starts with a global view of the entire problem and breaks the problem down into smaller, more manageab
In-s [12.5K]

Answer:

Top down design

Explanation:

Top-down design is an approach that is used to break down the problem into the smaller subpart so that it can be manageable into more clear form.

C programming is the example of a top-down approach while C++ is the example of the bottom-up approach.

The advantages of the top-down design approach are:

1) easy to manage

2) easy to find the error

3) easy to debug

4 0
2 years ago
Other questions:
  • AMSCO networks plans to conduct a poll of viewers during the SuperBowl. They will conduct analysis to determine which area of th
    6·2 answers
  • Designing, producing, exhibiting, performing, writing, and publishing multimedia content including visual and performing arts an
    6·1 answer
  • To print data sideways on a piece of paper, use the _______ page orientation setting.
    6·2 answers
  • Which of the following laptop features allows users to overcome keyboard size restrictions?
    11·1 answer
  • One blog may have a greater social influence than another when it has_______?
    12·2 answers
  • How do ice and water on the ground affect incoming solar radiation? They filter 22 percent of solar radiation that reaches the s
    9·2 answers
  • What should you do first when designing a program?
    5·2 answers
  • What is the usual price of smartphone apps?
    8·2 answers
  • A list is a collection that ______________
    9·1 answer
  • Which option should Gina click to edit the text contained in a text box on a slide in her presentation?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!