From 6b7a63c06eaa49351d207568b7716e9558d08f60 Mon Sep 17 00:00:00 2001 From: JacobAKnox <91796123+JacobAKnox@users.noreply.github.com> Date: Fri, 15 Oct 2021 21:59:39 -0700 Subject: Fixed partner's code --- FixedCode/FixedCode.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 FixedCode/FixedCode.cpp (limited to 'FixedCode/FixedCode.cpp') diff --git a/FixedCode/FixedCode.cpp b/FixedCode/FixedCode.cpp new file mode 100644 index 0000000..e1e9ab5 --- /dev/null +++ b/FixedCode/FixedCode.cpp @@ -0,0 +1,44 @@ +//Code by Jordan Harris-Toovy for OIT's CST116 course, October 2021 + +/* +* Pseudocode: +* DISPLAY Prompt for radius +* GET user input, put into variable radius +* +* DISPLAY Prompt for height +* GET user input, put into variable height +* +* Calculate volume, put into variable volume +* DISPLAY Prompt for volume +*/ + +#include +#include + +int main() +{ + float radius = 0.0F, height = 0.0F, volume = 0.0F, pi = 3.14159265359F; + + //Get values from user + std::cout << "Cylinder volume calculator MK1\n" << "Enter the radius of the cylinder: "; + std::cin >> radius; + + std::cout << "\nEnter the height of the cylinder: "; + std::cin >> height; + + //Exit if either input is less then zero + if ((radius < 0) || (height < 0)) + { + std::cout << "\nInvald input\n"; + return (1); + } + + //Calculate volume + volume = height * pi * radius * radius; + + //Display the volume + std::cout.setf(std::ios::fixed); + std::cout << "\n\nThe volume of the cylinder is: " << std::setprecision(2) << volume << std::endl; + + return (0); +} -- cgit v1.2.3