subject
Engineering, 18.03.2020 04:01 globalremix

The statements in the file main. cpp are in incorrect order.

Rearrange the statements so that they prompt the user to input:

The shape type (rectangle, circle, or cylinder)
The appropriate dimension of the shape.
Note: For grading purposes place the cylinder height statement before the radius statement.

The C++ 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
For a cylinder, it outputs the volume and surface area.
After rearranging the statements, your program should be properly indented.

Here is the code out-of-order:

using namespace std;

#include

int main()
{
string shape;
double height;
#include

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

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

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

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

cout << "Enter the width of the rectangle: ";
cin >> width;
cout << endl;

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

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

cout << "Volume of the cylinder = "
<< PI * pow(radius, 2.0)* height << endl;
double length;
}
return 0;

else if (shape == "cylinder")
{
double radius;

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

#include

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

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

ansver
Answers: 1

Another question on Engineering

question
Engineering, 03.07.2019 15:10
Heat is added to a piston-cylinder device filled with 2 kg of air to raise its temperature 400 c from an initial temperature of t1 27 cand pressure of pi 1 mpa. the process is isobaric process. find a)-the final pressure p2 b)-the heat transfer to the air.
Answers: 1
question
Engineering, 04.07.2019 08:10
Which of the following is an easy way to remember the modified “x” tire rotation? a. nondrive wheels straight, cross the drive wheels b. drive wheels straight, cross the nondrive wheels c. drive wheels crossed, nondrive wheels straight d. drive wheels crossed, nondrive wheels crossed
Answers: 1
question
Engineering, 04.07.2019 19:20
Apure substance is a)-mixture of various chemical elements or compounds b)-substance that has a fixed chemical composition throughout c)-mixture that is homogeneous (such as air) d)-all the answers
Answers: 3
question
Engineering, 06.07.2019 04:30
Briefly discuss how plastic deformation occurs in crystalline materials discuss the five most important methods of strengthening of metals and alloys.
Answers: 2
You know the right answer?
The statements in the file main. cpp are in incorrect order.

Rearrange the statements so...
Questions
question
Mathematics, 10.03.2021 01:00
question
Mathematics, 10.03.2021 01:00
question
Mathematics, 10.03.2021 01:00
question
Mathematics, 10.03.2021 01:00
question
Biology, 10.03.2021 01:00
question
Mathematics, 10.03.2021 01:00
question
Mathematics, 10.03.2021 01:00