blob: 9ea3bde8e97f4e6a57b0864acb4bc5ad7bdf0270 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
//In the next 30 minute, I will be comepleting the code for the cylinder volume calculator. I will also create a version with errors.
// I know the equation for the volume of a cylinder and how to get user input.
// I don't know if the volume will need to be a float or a double to contain a long decimal chain.
//
// Pseudo Code
// 1. Define variables for radius and height of a cylinder.
// 2. Ask user for input of radius and height.
// 3. Calculate volume of a cylinder with these perameters and print
//Jeffrey Wiser
//[email protected]
//We met in class the day after the assignment was given to swap our codes.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//define variable
float radius = 0;
float height = 0;
double volume = 0;
//ask for user input radius
cout << "Please enter the radius: ";
cin >> radius;
//ask for user input height
cout << "Please enter the height: ";
cin >> height;
//calculations
volume = radius * radius * height * 3.14159;
//output answer
cout << "The volume of the given cylinder is: " << volume << " units cubed.\n";
return 0;
}
|