summaryrefslogtreecommitdiff
path: root/CST116F2021-Proj1/Rayyan Ansari's code/Project1 - CST 116 - Rayyan Ansari.cpp
blob: e8eec4d00396c04f1470c1112ee99131d1789959 (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
//Code by Rayyan Ansari, modified by Jordan Harris-Toovy, October 2021

#include <iostream>
#include <iomanip>
using namespace std;
using std::ios;

int main()
{
    float radius;
    float height;
    float pi = 3.14159265;
    float volume;

    cout << "Please enter the radius of the Cylinder: ";
    cin >> radius; //Fixed missmatched variables
    cout << endl;

    cout << "Please enter the height of the Cylinder: ";
    cin >> height; //Fixed missmatched variables
    cout << endl;

    volume = radius * radius * pi * height;

    if (volume > 0) {
        cout << "The volume of a cylinder with height " << height << " and radius " << radius << " is ";

        cout.setf(ios::fixed); //Fixed missing colon
        cout << setprecision(3) << volume;
    }

    else {
        cout << "Volume cannot be negative";
    }
}