From 21e4caa4564b65ec52bb280a158bf3ab5b49dc60 Mon Sep 17 00:00:00 2001 From: Jordan HarrisToovy Date: Mon, 18 Oct 2021 02:26:32 -0700 Subject: Added Rayyan Ansari's code sample --- ...ST 116 - Rayyan Ansari-Fixed Console output.txt | 10 +++++++ .../Project1 - CST 116 - Rayyan Ansari.cpp | 35 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 CST116F2021-Proj1/Rayyan Ansari's code/Project1 - CST 116 - Rayyan Ansari-Fixed Console output.txt create mode 100644 CST116F2021-Proj1/Rayyan Ansari's code/Project1 - CST 116 - Rayyan Ansari.cpp diff --git a/CST116F2021-Proj1/Rayyan Ansari's code/Project1 - CST 116 - Rayyan Ansari-Fixed Console output.txt b/CST116F2021-Proj1/Rayyan Ansari's code/Project1 - CST 116 - Rayyan Ansari-Fixed Console output.txt new file mode 100644 index 0000000..e5dffce --- /dev/null +++ b/CST116F2021-Proj1/Rayyan Ansari's code/Project1 - CST 116 - Rayyan Ansari-Fixed Console output.txt @@ -0,0 +1,10 @@ +Console output for Project1 - CST 116 - Rayyan Ansari.cpp after fixes were applied: + +Please enter the radius of the Cylinder: 3 + +Please enter the height of the Cylinder: 5 + +The volume of a cylinder with height 5 and radius 3 is 141.372 +C:\Users\jorda\source\repos\CST_Testing\Debug\CST_Testing.exe (process 3252) exited with code 0. +To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops. +Press any key to close this window . . . 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 +#include +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 -- cgit v1.2.3