Question

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:

  1. The height of the base of a cylinder
  2. The radius of the base of a cylinder

The program then outputs (in order):

  1. The volume of the cylinder.
  2. The surface area of the cylinder

Format 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 of the cylinder: ";

cin >> radius;

cout << endl;

return 0;

double radius;

cout << "Surface area: "

<< 2 * PI * radius * height + 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
#include <iomanip>
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    const double PI = 3.14159;
    double height;
    double radius;

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

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

    cout << fixed << showpoint << setprecision(2);

    cout << "Volume of the cylinder = "<< PI * pow(radius, 2.0) * height << endl;
    cout << endl;
    
    cout << "Surface area: "<< 2 * PI * radius * height + 2 * PI * pow(radius, 2.0)<< endl;
    cout << endl;

    return 0;
}
Add a comment
Know the answer?
Add Answer to:
PLEASE TYPE OUT IN TEXT (please no pdf or writing) C++ CODE Consider the following program...
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
  • 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...

  • 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++ code for CIS054 Create a program that uses a function to determine the length of...

    C++ code for CIS054 Create a program that uses a function to determine the length of a line by inputting the X,Y coordinates of the line endpoints. Show the result with a precision of four decimal places. The function prototype is to be specified as follows:     double LengthOfLine (double X1, double Y1, double X2, double Y2); // returns length of line by using this code: #include <iostream> #include <iomanip> #include <cmath> using namespace std; int main(int argc, char* argv[])...

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

  • Please help me to write a program in C++ with comments and to keep it simple...

    Please help me to write a program in C++ with comments and to keep it simple as possible. Thank you! Here is my program I have done before and that need to be change: #include <iostream> #include <iomanip> using namespace std; // function prototype – returning one value double cylvol(double, double); // Note: two data types inside brackets double surfarea(double, double); // Note: two data types inside brackets int main() { double r, l, V, S; cout << setprecision(2) <<...

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

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

  • Write a C program named assignment04.cpp that will ask for and read in a float for...

    Write a C program named assignment04.cpp that will ask for and read in a float for a radius ask for and read in a float for the height each of the following functions will calculate some property of a shape (area, volume, circumference, etc) The functions will accept one or two parameters (radius and/or height) and return the proper calculation. There is no input/output (cin or cout) in the function – just the calculation write the following functions float areaCircle(float...

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
ADVERTISEMENT