Create a menu-driven program (using the switch) that finds and displays areas of 3 different objects.
The menu should have the following 4 choices:
1 -- rectangle
2 -- circle
3 -- triangle
4 -- quit
If the user selects anything else (i.e., an invalid choice) an appropriate error message should be printed.
HINTS:
// 1. DEFINE THE NAMED CONSTANT PI AND SET ITS VALUE TO
3.14159
// 2. DECLARE ALL NEEDED VARIABLES and GIVE EACH ONE A DESCRIPTIVE
NAME
// AND AN APPROPRIATE DATA TYPE.
// 3. USE AN IF/ELSE IF STATEMENT TO OBTAIN ANY NEEDED INPUT
INFORMATION
// AND COMPUTE AND DISPLAY THE AREA FOR EACH VALID MENU
CHOICE.
// 4. IF AN INVALID MENU CHOICE WAS ENTERED, AN ERROR MESSAGE
SHOULD
// BE DISPLAYED.
Sample Run
Program to calculate areas of objects
1 -- rectangle
2 -- circle
3 -- triangle
4 -- quit
2
Radius of the circle: 3.0
Area = 28.2743
Program:
#include <iostream>
using namespace std;
int main()
{
int ch;
cout<<"1).rectangle"<<endl;
cout<<"2).circle"<<endl;
cout<<"3).triangle"<<endl;
cout<<"4).quit"<<endl;
cout<<"Enter your choice: ";
cin>>ch;
switch(ch)
{
case 1:
float l,w;
cout<<"Length of rectangle: ";
cin>>l;
cout<<"Width of rectangle: ";
cin>>w;
cout<<endl<<"Area: "<<(l*w);
break;
case 2:
float r;
cout<<"Radius of the circle: ";
cin>>r;
cout<<endl<<"Area: "<<(3.14159 * r * r);
break;
case 3:
float b,h;
cout<<"Base of circle: ";
cin>>b;
cout<<"Height of circle: ";
cin>>h;
cout<<endl<<"Area: "<<(b* h* 0.5);
break;
case 4:
cout<<"You choose to quit, bye!";
break;
default:
cout<<"Invalid choice";
break;
}
return 0;
}
Output:


Create a menu-driven program (using the switch) that finds and displays areas of 3 different objects....
Design program so that it correctly meets the program specifications given below. Specifications: Create a menu-driven program that finds and displays areas of 3 different objects. The menu should have the following 4 choices: 1 -- square 2 -- circle 3 -- right triangle 4 -- quit If the user selects choice 1, the program should find the area of a square. If the user selects choice 2, the program should find the area of a circle. If the user...
Menu-driven programs will display the menu options to the user and then prompt them for a menu choice. This program will display the following menu in the following format: Calculator Options: Calculate the area of a circle Calculate the area of a rectangle Calculate the area of a triangle Calculate the area of a trapezoid Calculate the area of a sphere Exit Enter your choice (1-6) Once the user enters a choice for the menu, the program should use a...
Java only please Write a program that displays the following menu: Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Triangle 3. Calculate the Area of a Rectangle 4. Quit Enter your choice (1-4): If the user enters 1, the program should ask for the radius of the circle and then display its area. Use the formula: area = ∏r2 Use 3.14159 for ∏. If the user enters 2 the program should ask for...
Geometric calclator use python to do this program. Write a program that displays the following menu: 1. Calculate the area of circle 2. calculate the area of rectangle 3. calculate the area of triangle 4. Quit Enter your choice (1-4). if the user enters 1, your program should ask for the radius of the circle and then display its area. Use the formula to calculate the circle's area: Area = pi*r^2 Use 3.14149 for Pi and the radius of the...
(PYTHON) Write a program that displays the following menu:. , Write Algorithm for Code Geometry Calculator 1. Calculate the Area of a Circle 2. Calculate the Area of a Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1 - 4): If the user enters 1, the program should ask for the radius of the circle and then display its area. If the user enters 2, the program should ask for the length and width of...
Q2: Write a menu-driven C program using switch-case to calculate the following: 1. Area of circle 2. Area of square 3. Area of rectangle The program should use the following functions properly: void displayMenu() //a function that will display the menu options to the user int getChoice() //a function that will input the user choice and returns it float calculate(int choice) //a function that reads the required inputs based on the user choice, and returns the area of the shape...
C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...
Lab 5 Areas.cpp Marisol Castellanos villa #include # include using nanespace std; int main // ?NCLUDE ANY NEEDED FILES HERE ciostrean cmath.ho const double PI 3.14159 DEFINE THE NAMED CONSTANT PI HERE AND SET ITS VALUE TO 3.14159 oat c radius, c area; loat s side, s area float t-height, tvidth, tarea; int choice: char ch; de // DECLARE ALL NEEDED VARIABLES HERE. GIVE EACH ONE A DESCRIPT?VE /I NAME AND AN APPROPRIATE DATA TYPE coutec"Progran to calculate areas of...
Write a program that will maintain a personal phonebook. The program should be menu driven. Create a new phonebook Print the phonebook Add person to the phonebook Remove a person from the phonebook Sort Modify a person Search for a person by name Save to a data file (Can't be done but leave an error message if the user selects) Retreive phonebook from data file (Can't be done but leave an error message if the user selects) Quit Create a...
Please use C++ and output have to look like that
Create a menu driven C++ program with functions. There must be four functions, calculating the size of area of circle, rectangle, triangle, and parallelogram. You are required to create those four functions and invoke them from the main program in order to reccive any credit. Please Submit: . A flowchart of your program with equations and expected results. 4 points) 2. Printout of your C++program with a heading comment, also...