Answer to Question #246903 in C++ for Tony

Question #246903
Write a program that prompts the user to input the shape type such as circle,

rectangle, and rectangular prism and the appropriate dimension of the shape. The

program then outputs the following information about the shape: For a circle, it outputs

the area and circumference; for rectangle, outputs the perimeter and area, and for a

rectangular prism, outputs the volume and surface area.
1
Expert's answer
2021-10-05T18:16:11-0400
#include<iostream>
#include<math.h>
using namespace std;
int main(){
	int x;
	do{
		
		
	
	cout<<"Enter the shape type such as circle, rectangle, and rectangular prism\n";
	string shape;
	getline(cin, shape);
	if(shape=="circle"){
		cout<<"Enter the radius of the circle\n";
		int rad;
		cin>>rad;
		cout<<"The area of the circle is:  "<<3.142 * rad * rad <<endl;
		cout<<"The area of the circle is:  "<<2 * 3.142 * rad <<endl;
	}
	else if(shape== "rectangle"){
		cout<<"Enter the width of the rectangle\n";
		int wid;
		cin>>wid;
		cout<<"Enter the length of the rectangle\n";
		int len;
		cin>>len;
		cout<<"The area of the rectangle is:  "<<len * wid<<endl;
		cout<<"The perimeter of the rectangle is:  "<<2*(len + wid)<<endl;
	}
	else if(shape == "rectangular prism"){
		int length, width, height;
		cout<<"Enter the length of the rectangular prism:\n ";
		cin>>length;
		cout<<"Enter the width of the rectangular prism:\n ";
		cin>>width;
		cout<<"Enter the height of the rectangular prism:\n ";
		cin>>height;
		cout<<"The surface area of the rectangular prism:  "<<2* (length * width +  width* height + width *  height)<<endl;
		cout<<"The volume of the rectangular prism:  "<< length * width *height<<endl;
		
		
		
		
	}
	cout<<"Enter 0 to terminate the program or 1 to continue\n";
	cin>>x;
	
	}while(x!=0);
	cout<<"Terminated successfully\n";
}

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

Tony
06.10.21, 03:38

Thank U Very much its big to me❤️

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS