Please complete the following computer problem. You will list the: inputs, outpu
ID: 3679769 • Letter: P
Question
Please complete the following computer problem. You will list the: inputs, outputs, pseudocode, flowchart, desk check and C++ code as a .cpp file.
Here is the problem:
Write a program that reads in the radius and length of a cylinder and computes the area and volume using the following formulas: area = radius * radius * PI (Where PI is the constant that represents 3.14) volume = area * length
Here is a sample run: Enter the radius and length of a cylinder: 5.5 12 (enter) The area is 94.985 The volume is 1139.82
Explanation / Answer
#include <iostream>
using namespace std;
#include <cmath>
int main()
{
double radius = 0.0;
double length = 0.0;
const double PI = 3.14159;
double area = 0.0;
double volume = 0.0;
// I
cout << "Enter the radius and length of a cylinder ";
cin >> radius >> length;
// P
area = pow(radius, 2.0) * PI;
volume = area * length;
// O
cout << "The area is " << area << endl;
cout << "The volume is " << volume << endl;
return 0;
}
sample output
Enter the radius and length of a cylinder 5.5 12
The area is 95.0331
The volume is 1140.4
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.