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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:20
[a] create a class called “cycle” which has two instance integer variables as properties, “numberofwheels” and “weight.” create a constructor with two parameters, using the same variable names in the parameter list. assign each variable to numberofwheels” and “weight” respectively. write a separate application to test the class and display its properties. note: do not change the names of the instance variables or the variables listed in the constructor’s parameter list. [b] edit your class cycle by adding a default constructor which will assign the default values of 100 to represent the numberofwheels, and 1000 to represent the weight, by invoking a call to the other constructor. modify your application created in [a] to test the class.
Answers: 3
question
Computers and Technology, 22.06.2019 18:30
Which of the following is an example of intellectual properly! oa. new version of a novelb. journal of ideasc. pages of a bookood. lines of a poem
Answers: 2
question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. peter has launched a website that features baby products. however, clients often find they are unable to access the website because the server is down. which feature of cybersecurity should peter focus on for his website? a. data authenticity b. data privacy c. data availability d. data integrity e. data encryption
Answers: 3
question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. a company wants to use online methods to target more customers. it decides to conduct a market research by collecting the data of a few customers with their consent. they want to track data of the sites that their customers frequently visit. which software can the company? a. spyware b. bots c. adware d. trojan horse e. rootkits
Answers: 1
You know the right answer?
4. the statements in the following program are in incorrect order. rearrange the statements so that...
Questions
question
Social Studies, 23.06.2019 11:00
question
Social Studies, 23.06.2019 11:00