Question
Code should be written in C++

2. [11] You have been hired by Shapes Calculator Menu Maker to create a C++ console application that prompts the user with a
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below::

#include <iostream>
#include <iomanip>
using namespace std;
const int WIDTH = 10;
const float PI = 3.14;
void printMenu(){
   cout<<"a. Sphere"<<endl;
   cout<<"b. Right Circular Cylinder"<<endl;
   cout<<"c. Rectangle Parallelepiped"<<endl;
   cout<<"d. Cone"<<endl;
   cout<<"x. Exit"<<endl;
   cout<<"Enter your choice : ";
}
int main(){
   char choice;
   double r,l,h,w,vol;
   printMenu();
   cin>>choice;
   cout << fixed << showpoint << setprecision(2);
   switch(choice){
   case 'a':
       cout<<"Enter radius : ";
       cin>>r;
       vol = 4.0/3*PI*r*r*r;
       cout << setw(WIDTH) << left << "Radius"<<r<<endl;
       cout << setw(WIDTH) << left << "Volume"<<vol<<endl;
       break;
   case 'b':
       cout<<"Enter radius : ";
       cin>>r;
       cout<<"Enter height : ";
       cin>>h;
       vol = PI*r*r*h;
       cout << setw(WIDTH) << left << "Radius"<<r<<endl;
       cout << setw(WIDTH) << left << "Height"<<h<<endl;
       cout << setw(WIDTH) << left << "Volume"<<vol<<endl;
       break;
   case 'c':
       cout<<"Enter length : ";
       cin>>l;
       cout<<"Enter Width : ";
       cin>>w;
       cout<<"Enter height : ";
       cin>>h;
       vol = l*w*h;
       cout << setw(WIDTH) << left << "Length"<<l<<endl;
       cout << setw(WIDTH) << left << "Width"<<w<<endl;
       cout << setw(WIDTH) << left << "Height"<<h<<endl;
       cout << setw(WIDTH) << left << "Volume"<<vol<<endl;
       break;
   case 'd':
       cout<<"Enter radius : ";
       cin>>r;
       cout<<"Enter height : ";
       cin>>h;
       vol = 1.0/3*PI*r*r*h;
       cout << setw(WIDTH) << left << "Radius"<<r<<endl;
       cout << setw(WIDTH) << left << "Height"<<h<<endl;
       cout << setw(WIDTH) << left << "Volume"<<vol<<endl;
       break;
   default:
       cout<<"Please enter correct option"<<endl;
       break;

   }

   return 0;
}

output:

Console 3 terminated> CPP Workspace.exe [C/C+ a. Sphere b. Right Circular Cylinder C. Rectangle Parallelepiped x. Exit ter yo

E Console <terminated> CPP_Workspace.exe [C/C++ Application] a. Sphere b. Right Circular Cylinder c. Rectangle Parallelepiped

Add a comment
Know the answer?
Add Answer to:
Code should be written in C++ 2. [11] You have been hired by Shapes Calculator Menu Maker to create a C++ console a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Menu-driven programs will display the menu options to the user and then prompt them for a...

    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...

  • I have this c++ program that i have to create but i am stuck on it....

    I have this c++ program that i have to create but i am stuck on it. Write a height conversion program that shall allow user to convert from feet and inches to meters (option 1) and vice versa (option 2). User shall be able to specify the type of conversion (a menu of two options). Display an error message if an invalid option is specified. Otherwise, the program would read in a length in feet and inches (two separate integer...

  • Write a C++ console application that uses functions to calculate an employee’s salary.

    Write a C++ console application that uses functions to calculate an employee’s salary.PART 1: Create a void function to print a menu asking the user to choose from the following options:1 - Annual salary2 - Monthly salary3 - Daily rate of pay4 – ExitThe void function only prints the menu. Format your cout statement to include the menu as displayed above.If the chosen option is 1- Annual Salary, ask the user for the number of hours they work perweek and...

  • CE – Return and Overload in C++ You are going to create a rudimentary calculator. The...

    CE – Return and Overload in C++ You are going to create a rudimentary calculator. The program should call a function to display a menu of three options: 1 – Integer Math 2 – Double Math 3 – Exit Program The program must test that the user enters in a valid menu option. If they do not, the program must display an error message and allow the user to reenter the selection. Once valid, the function must return the option...

  • Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve...

    Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve the following program. -Use Microsoft Visual C++ .NET 2010 Professional compiler using default compiler settings. -Use Microsoft Visio 2013 for developing your flowchart. -Adherence to the ANSI C++  required -Do not use <stdio.h> and <conio.h>. -Do not use any #define in your program. -No goto statements allowed. Upon execution of the program, the program displays a menu as shown below and the user is prompted to make a selection from the menu....

  • In this project you will create a console C++ program that will have the user to...

    In this project you will create a console C++ program that will have the user to enter Celsius temperature readings for anywhere between 1 and 365 days and store them in a dynamically allocated array, then display a report showing both the Celsius and Fahrenheit temperatures for each day entered. This program will require the use of pointers and dynamic memory allocation. Getting and Storing User Input: For this you will ask the user how many days’ worth of temperature...

  • this is how output should look CSC1101 TakeHome Lab02 (1),docx - Compatibility Mode Saved to this PC S Review View. Help Search 3. [11] You have been hired by Projectile Objects to create a...

    this is how output should look CSC1101 TakeHome Lab02 (1),docx - Compatibility Mode Saved to this PC S Review View. Help Search 3. [11] You have been hired by Projectile Objects to create a calculator for various equations from kinematics. Suppose someone shoots an object and it does projectile motion with an angle of 30, 45 and 60 degrees to the horizontal. Choose it's initial velocity (ex. 10 m/s) find the maximum height it can reach, horizontal displacement and total...

  • C++ should be used C++ should be used CSC1101 TakeHome Lab02 (1),docx - Compatibility Mode Saved to this PC s Review View Help ρ Search 3. [11] You have been hired by Projectile Objects to cre...

    C++ should be used C++ should be used CSC1101 TakeHome Lab02 (1),docx - Compatibility Mode Saved to this PC s Review View Help ρ Search 3. [11] You have been hired by Projectile Objects to create a calculator for various equations from kinematics. Suppose someone shoots an object and it does projectile motion with an angle of 30, 45 and 60 degrees to the horizontal. Choose it's initial velocity (ex. 10 m/s) find the maximum height it can reach, horizontal...

  • C++ programming For this assignment, write a program that will act as a geometry calculator. The...

    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...

  • C++ Fraction calculator Need help with code, cant use "using namespace std" Objectives Create and use...

    C++ Fraction calculator Need help with code, cant use "using namespace std" Objectives Create and use functions. Use a custom library and namespace. Use reference variables as parameters to return values from functions. Create a robust user interface with input error checking. Use exceptions to indicate errors. Resources kishio.h kishio.cpp Assignment requirements You will need eight methods (including main). One is given to you. Their requirements are specified below: menu: The menu function takes no arguments, but returns a char...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT