Based on the image attached, shows a statement of a program are 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 outputs the volume and surface area. After rearranging the statements, your program should be properly indented.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

EXERCISE WEEK 7 (USE C++ CODING)

Based on the image attached, shows a statement of a program are 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 outputs the volume and surface area. After rearranging the statements, your program should be properly indented.

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 <iomanip>
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 <cmath>
}
Transcribed Image Text: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 <iomanip> 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 <cmath> }
using namespace std;
#include <iostream>
int main()
{
string shape;
double height;
#include <string>
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;
out << "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 << endl;
Transcribed Image Text:using namespace std; #include <iostream> int main() { string shape; double height; #include <string> 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; out << "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 << endl;
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 5 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education