diff options
| -rw-r--r-- | CST116F2021-Proj1/CST116F2021-Proj1.cpp | 38 | ||||
| -rw-r--r-- | WiserProj1Main.cpp | 32 |
2 files changed, 55 insertions, 15 deletions
diff --git a/CST116F2021-Proj1/CST116F2021-Proj1.cpp b/CST116F2021-Proj1/CST116F2021-Proj1.cpp index 8bcb373..28948d4 100644 --- a/CST116F2021-Proj1/CST116F2021-Proj1.cpp +++ b/CST116F2021-Proj1/CST116F2021-Proj1.cpp @@ -1,20 +1,28 @@ -// CST116F2021-Proj1.cpp : This file contains the 'main' function. Program execution begins and ends there. -// +//Pseudo Code +// 1. Define variables for radius and height of a cylinder. +// 2. Ask user for input of radius and height. +// 3. Calculate volume of a cylinder with these perameters and print #include <iostream> +#include <iomanip> +using namespace std; int main() { - std::cout << "Hello World!\n"; -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file + float radius = 0; + float height = 0; + double volume = 0; + + cout << "Please enter the radius: "; + cin >> radius; + + cout << "Please enter the height: "; + cin >> height; + + volume = radius * radius * height * 3.14159; + + cout << "The volume of the given cylinder is: " << volume << " units cubed.\n"; + + return 0; + +}
\ No newline at end of file diff --git a/WiserProj1Main.cpp b/WiserProj1Main.cpp new file mode 100644 index 0000000..c3636ad --- /dev/null +++ b/WiserProj1Main.cpp @@ -0,0 +1,32 @@ +//Pseudo Code +// 1. Define variables for radius and height of a cylinder. +// 2. Ask user for input of radius and height. +// 3. Calculate volume of a cylinder with these perameters and print + +#include <iostream> +#include <iomanip> +using namespace std; + +int main() +{ + //define variable + float radius = 0; + float height = 0; + double volume = 0; + + //ask for user input radius + cout << "Please enter the radius: "; + cin >> radius; + + //ask for user input height + cout << "Please enter the height: "; + cin >> height; + + //calculations + volume = radius * radius * height * 3.14159; + + //output answer + cout << "The volume of the given cylinder is: " << volume << " units cubed.\n"; + + return 0; +}
\ No newline at end of file |