Question

Consider the following program in which the statements are in the incorrect order. Rearrange the statements...

Consider the following program in which the statements are in the incorrect order. Rearrange the statements so that the program prompts the user to input the height and the radius of the base of a cylinder and outputs the volume and surface area of the cylinder. Formant the output to two decimal places.

#include <iomanip>
#include <cmath>

int main ()
{}

double height;

cout << ”Volume of the cylinder = “
<<PI * pow(radius, 2.0) * height << endl;

cout << “Enter the height if the cylinder: “;
cin >> radius;
cout << endl;

return 0;

double radius;

cout << “Surface area: “
<< 2 * radius * + 2 * PI * pow (radius, 2.0) << endl;
cout << fixed << showpoint << setprecision (2);

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

#include <iostream>
const double PI = 3.14159;

using namespace std;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The correct order of the code is as follows:

Program screenshot:

#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() const double PI = 3.14159; double hei

Sample output:

Enter the height if the cylinder: 6 Enter the radius of the base of the cylinder: 2 Volume of the cylinder = 75.40 Surface ar

Code to copy:

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main ()
{
const double PI = 3.14159;
double height;
double radius;

cout << "Enter the height if the cylinder: ";
cin >> height;
cout << endl;
cout << "Enter the radius of the base of the cylinder: ";
cin >> radius;
cout << endl;
cout << fixed << showpoint << setprecision (2);
cout << "Volume of the cylinder = "
<<PI * pow(radius, 2.0) * height << endl;

cout << "Surface area: "
<< 2 * radius * + 2 * PI * pow (radius, 2.0) << endl;
return 0;
}

Add a comment
Know the answer?
Add Answer to:
Consider the following program in which the statements are in the incorrect order. Rearrange the statements...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PLEASE TYPE OUT IN TEXT (please no pdf or writing) C++ CODE Consider the following program...

    PLEASE TYPE OUT IN TEXT (please no pdf or writing) C++ CODE Consider the following program in which the statements are in the incorrect order. Rearrange the statements in the following order so that the program prompts the user to input: The height of the base of a cylinder The radius of the base of a cylinder The program then outputs (in order): The volume of the cylinder. The surface area of the cylinder Format the output to two decimal...

  • The statement in the following program is in the incorrect order. Rearrange the statements so that...

    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...

  • I'm trying to write a program that can ask a user about what type of solid...

    I'm trying to write a program that can ask a user about what type of solid they have and to be able to enter values like radius and length of the shape so the program can calculate the volume of a shape and print the result. I also want to give them a repeating option to input another shape if they want to. I'm trying to use at least 7 functions that can display an output, the volumes of a...

  • In C++ Amanda and Tyler opened a business that specializes in shipping liquids, such as milk,...

    In C++ Amanda and Tyler opened a business that specializes in shipping liquids, such as milk, juice, and water, in cylindrical containers. The shipping charges depend on the amount of the liquid in the container. (For simplicity, you may assume that the container is filled to the top.) They also provide the option to paint the outside of the container for a reasonable amount. Write a program that does the following: Prompts the user to input the dimensions (in feet)...

  • The value of π can be approximated by using the following series: The program in main.cpp...

    The value of π can be approximated by using the following series: The program in main.cpp uses this series to find the approximate value of π. However, the statements are in the incorrect order, and there is also a bug in this program. Rearrange the statements and remove the bug so that this program can be used to approximate π. The code that they have: #include <iostream> #include <iomanip> using namespace std; int main() {     double pi = 0;     long...

  • c++ Please help! i keep getting an error message. I think my main problem is not...

    c++ Please help! i keep getting an error message. I think my main problem is not understanding the circle calculations function and how both the area and the circumference is returned from the function. I know & needs to be used, but I am unsure how to use it. Copy the following code and run it. You should break it into the following 3 functions getValidinput - which asks the user to enter the radius and then make sure that...

  • In this exercise, you will modify the hypotenuse program shown earlier in Figure 9-6. Follow the...

    In this exercise, you will modify the hypotenuse program shown earlier in Figure 9-6. Follow the instructions for starting C++ and viewing the ModifyThis13.cpp file, which is contained in either the Cpp8/Chap09/ModifyThis13 Project folder or the Cpp8/Chap09 folder. Remove both calculation tasks from the main function, and assign both to a program-defined value-returning function named getHypotenuse. Test the program appropriately. //Hypotenuse.cpp - displays the length of a right //triangle's hypotenuse #include <iostream> #include <iomanip> #include <cmath> using namespace std; int...

  • Exercise 5.5 (EASY) for beginning CS CLASS PART A Copy or cut and paste program P5_2.cpp...

    Exercise 5.5 (EASY) for beginning CS CLASS PART A Copy or cut and paste program P5_2.cpp (located below) to a new program called ex55.cpp. Make PI a constant value. Compile and run the program for the following values: r = 2 cm, h = 10 cm The correct answer should be:       The cross-section area of the cylinder is 3.89556 inch-sq       The side area of the cylinder is 19.4778 inch-sqr Did you get the correct answer? You didn't! Explain...

  • Open with Drive N // Test1B-Debug.cpp .This is a program with 6 errors in it Find and fix each er...

    NEED HELP WITH THIS!! Open with Drive N // Test1B-Debug.cpp .This is a program with 6 errors in it Find and fix each error. // Simple Container made from circular paper // Test-1B Debug Program #include #include

  • can someone assist me and tell me what I'm missing. I managed to get it this...

    can someone assist me and tell me what I'm missing. I managed to get it this far but still missing two parts to complete it. CENGAGE MINDTAP Programming Exercise 6-4 Tasks main.cpp + 1 #include <iostream r with successful Uses piand 2 #include <cnath> output 5,00 out of 10.00 3 using nanespace std; 4 5 const double PI = 3.1419; 2 out of 4 checks passed. Review 6 the results below for more details. 7 int main() 8 ( Checks...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT