diff options
| -rw-r--r-- | CST116F2021-Proj1/Jacob Knox's code/BrokenCode-Fixed Console output.txt | 8 | ||||
| -rw-r--r-- | CST116F2021-Proj1/Jacob Knox's code/BrokenCode.cpp | 22 |
2 files changed, 30 insertions, 0 deletions
diff --git a/CST116F2021-Proj1/Jacob Knox's code/BrokenCode-Fixed Console output.txt b/CST116F2021-Proj1/Jacob Knox's code/BrokenCode-Fixed Console output.txt new file mode 100644 index 0000000..dc89dbb --- /dev/null +++ b/CST116F2021-Proj1/Jacob Knox's code/BrokenCode-Fixed Console output.txt @@ -0,0 +1,8 @@ +Console output for BrokenCode.cpp after fixes were applied: + +Input the cylinder's radius: 5 +Input the cylinder's height: 6 +The volume of a cyliner with radius: 5.000, and height: 6.000, is 471.300 +C:\Users\jorda\source\repos\CST_Testing\Debug\CST_Testing.exe (process 6388) 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 . . .
\ No newline at end of file diff --git a/CST116F2021-Proj1/Jacob Knox's code/BrokenCode.cpp b/CST116F2021-Proj1/Jacob Knox's code/BrokenCode.cpp new file mode 100644 index 0000000..4b2e000 --- /dev/null +++ b/CST116F2021-Proj1/Jacob Knox's code/BrokenCode.cpp @@ -0,0 +1,22 @@ +//Original code by Jacob Knox. Modified by Jordan Harris-Toovy + +// BrokenCode.cpp : This file contains the 'main' function. Program execution begins and ends there. +//This file has one logic and one syntax error + +#include <iostream> +using namespace std; + +int main() +{ + const double PI = 3.142; + double radius, height, volume; + + cout << "Input the cylinder's radius: "; + cin >> radius; + cout << "Input the cylinder's height: "; + cin >> height; + + volume = radius * radius * PI * height; //Fixed issue where radius was multiplied three times + cout.precision(3); + cout << fixed << "The volume of a cyliner with radius: " << radius << ", and height: " << height << ", is " << volume; //Fixed issue where + was used instad of << +} |