Question: The statement in the following program is in the incorrect order. Rearrange the statements so that they prompt the user to input the shape type

The statement in the following program is in the incorrect order. Rearrange the statements so that they prompt the user to input the shape type (rectangle, circle, or cylinder) and the appropriate dimension of the shape. The program then outputs the following information about the shape: For a rectangle, it outputs the area and perimeter, for a circle, it outputs the area and circumference; and for a cylinder, it output the volume and surface area. After rearranging the statements, your program should be properly indented. Please make sure that the output is two decimals points.

using namespace std;

#include

int main() { string shape; double height;

#include

cout << "Enter the shape type: (rectangle, circle, cylinder) "; cin >> shape; cout << end1;

if (shape == "rectangle") { cout << "Area of the circle = " << PI * pow(radius, 2.0) << end1;

cout << "Circumference of the circle: " << 2 * PI * radius << end1;

cout << "Enter the height of the cylinder: "; cin >> height; cout << end1;

cout << "Enter the width of the rectangle; "; cin >> width; cout << end1;

cout << "Perimeter of the rectangle = " << 2 * (length + width) << end1; double width; }

cout << "Surface area of the cylinder: " << 2 * PI * radius * height + 2 * PI * pow(radius, 2.0) << end1; } else if (shape == "circle") { cout << "Enter the radius of the circle; '; cin >> radius; cout << end1;

cout << "Volume of the cylinder = " << PI * pow(radius, 2.0)* height << end1; double length; } return 0; else if (shape == "cyclinder") { double radius;

cout << "Enter the length of the rectangle: "; cin >> length; cout << end1;

#include

cout << "Enter the radius of the base of the cylinder: "; cin >> radius; cout << end1;

const double PI = 3.1416; cout << "Area of the rectangle = " << length * width << end1; else cout << "The program does not handle " << shape << end1; cout << fixed << showpoint << setprecision(2) ;

#include }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!