diff options
Diffstat (limited to 'CST116F2021-Proj1/Rayyan Ansari's code/Project1 - CST 116 - Rayyan Ansari.cpp')
| -rw-r--r-- | CST116F2021-Proj1/Rayyan Ansari's code/Project1 - CST 116 - Rayyan Ansari.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/CST116F2021-Proj1/Rayyan Ansari's code/Project1 - CST 116 - Rayyan Ansari.cpp b/CST116F2021-Proj1/Rayyan Ansari's code/Project1 - CST 116 - Rayyan Ansari.cpp new file mode 100644 index 0000000..e8eec4d --- /dev/null +++ b/CST116F2021-Proj1/Rayyan Ansari's code/Project1 - CST 116 - Rayyan Ansari.cpp @@ -0,0 +1,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"; + } +}
\ No newline at end of file |