subject

4. the statements in the following program are in 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 outputs the volume and surface area. after rearranging the statements, your program should be properly indented.

this is the code:

using namespace std;
#include
#include
#define pi 3.14159
int main()
{
string shape;
double height, radius;
cout < < "enter the shape type: (rectangle, circle, cylinder) ";
cin > > shape;
cout < < endl;
if (shape == "rectangle")
{
cout < < "enter the width of the rectangle: ";
cin > > width;
cout < < "enter the height of the rectangle: ";
cin > > height;
cout < < "area of the rectangle = " < < height * width < < endl;
cout < < "perimeter of the rectangle = " < < 2 * (height + width) < < endl;
}
if (shape == "circle")
{
cout < < "enter the radius of circle: ";
cin > > radius;
cout < < "area of the circle = " < < pi * pow(radius, 2.0) < < endl;
cout < < "perimeter of circle = " < < pi * radius * 2.0 < < endl;
}
if (shape == "cylinder")
{
cout < < "enter the radius of cylinder: ";
cin > > radius;
cout < < "enter the height of the cylinder: ";
cin > > height;
cout < < endl;
cout < < "volume of the cylinder = " < < pi * pow(radius, 2.0) * height < < endl;
cout < < "surface area of cylinder = " < < ( 2 * pi * pow(radius, 2.0) ) + ( pi * radius * 2.0 * height ) < < endl;
}
cout < < endl;

i'm getting the following errors when i compile the application:

using namespace std;
#include
#include
#define pi 3.14159
int main()
{
string shape;
double height, radius;
cout < < "enter the shape type: (rectangle, circle, cylinder) ";
cin > > shape;
cout < < endl;
if (shape == "rectangle")
{
cout < < "enter the width of the rectangle: ";
cin > > width;
cout < < "enter the height of the rectangle: ";
cin > > height;
cout < < "area of the rectangle = " < < height * width< < endl;
cout < < "perimeter of the rectangle = " < < 2 * (height + width) < < endl;
}
if (shape == "circle")
{
cout < < "enter the radius of circle: ";
cin > > radius;
cout < < "area of the circle = " < < pi * pow(radius, 2.0)< < endl;
cout < < "perimeter of circle = " < < pi * radius * 2.0< < endl;
}
if (shape == "cylinder")
{
cout < < "enter the radius of cylinder: ";
cin > > radius;
cout < < "enter the height of the cylinder: ";
cin > > height;
cout < < endl;
cout < < "volume of the cylinder = " < < pi * pow(radius, 2.0) * height < < endl;
cout < < "surface area of cylinder = " < < ( 2 * pi * pow(radius, 2.0) ) + ( pi * radius * 2.0 * height ) < < endl;
}
cout < < endl;

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 22:30, Metlife
You are new to microsoft certification and want to start out by getting a certification geared around windows 8. what microsoft certification should you pursue?
Answers: 1
image
Computers and Technology, 23.06.2019 09:00, amberpublow7
Which best describes the role or restriction enzymes in the analysis of edna a. to break dna into fragments that vary in size so they can be sorted and analyzed b. to amplify small amounts of dna and generate large amounts of dna for analysis c. to purify samples of dna obtained from the environment so they can be analyzed d. to sort different sizes of dna fragments into a banding pattern that can be analyzed
Answers: 1
image
Computers and Technology, 23.06.2019 18:00, teamroper35
Which finger presses the h key on the keyboard? index finger on the left hand pinky finger on the right hand index finger on the right hand thumb on the left hand
Answers: 1
image
Computers and Technology, 23.06.2019 19:30, carcon2019
Amitha writes up a one-page summary of a novel during her summer internship at a publishing company. when she reads over the page, she realizes she used the word “foreshadow” seven times, and she would like to reduce the repetition. which tool would best amitha solve this problem?
Answers: 3
You know the right answer?
4. the statements in the following program are in incorrect order. rearrange the statements so that...

Questions in other subjects:

Konu
Mathematics, 08.11.2019 04:31