Answer to Question #260732 in C++ for comscie

Question #260732

Write a program that will display a menu for the user to select what computation




to use. And compute the required outputs for each option. (see below the sample




menu). Use functions for this program.




M EN U




A] Compute area and circumference of Circle




B] Compute area and perimeter of a Rectangle




C] Compute Surface area and volume of a Cylinder




D] exit

1
Expert's answer
2021-11-03T17:47:46-0400
#include<iostream>
using namespace std;
int main()
{
	char option;
	cout<<"Select an option: "<<endl;
	cout<<"A] Compute area and circumference of Circle\nB] Compute area and perimeter of a Rectangle\nC] Compute Surface area and volume of a Cylinder\nD] exit\n";
    cin>>option;
    if(option=='A'||option=='a'){
    	int r;
    	double Area,circumference;
    	cout<<"Enter the radius: ";
    	cin>>r;
    	Area=3.142*r*r;
    	circumference=3.142*2*r;
    	cout<<"Area is: "<<Area<<endl;
    	cout<<"circumference: "<<circumference<<endl;	
	}
	else if(option=='B' ||option=='b'){
		int l,w,perimeter;
		double Area;
		cout<<"Enter the length and the width of the rectangle: "<<endl;
		cin>>l>>w;
		Area=l*w;
		perimeter=2*(l+w);
		cout<<"Area is: "<<Area<<endl;
		cout<<"Perimeter is: "<<perimeter<<endl;
	}
	else if(option=='C'||option=='c'){
		int r,h;
		double Area,volume;
		
		cout<<"Enter the radius and heigth: "<<endl;
		cin>>r>>h;
		Area=(2*3.142*r*h)+(2*3.142*r*r);
		volume=3.142*r*r;
		cout<<"Area is: "<<Area<<endl;
		cout<<"Volume is: "<<volume;
	}
	else{
		cout<<" ";
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS