From 9d53d8857eaa1c9405894a88ca75bc4657e42f35 Mon Sep 17 00:00:00 2001 From: msglm Date: Sat, 14 Jan 2023 05:31:48 -0600 Subject: Inital Commit --- C++/cubeSwitch/Ch 4 Cube program instructions.docx | Bin 0 -> 28802 bytes C++/cubeSwitch/cubeSwitch.cpp | 95 +++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 C++/cubeSwitch/Ch 4 Cube program instructions.docx create mode 100644 C++/cubeSwitch/cubeSwitch.cpp (limited to 'C++/cubeSwitch') diff --git a/C++/cubeSwitch/Ch 4 Cube program instructions.docx b/C++/cubeSwitch/Ch 4 Cube program instructions.docx new file mode 100644 index 0000000..f59110d Binary files /dev/null and b/C++/cubeSwitch/Ch 4 Cube program instructions.docx differ diff --git a/C++/cubeSwitch/cubeSwitch.cpp b/C++/cubeSwitch/cubeSwitch.cpp new file mode 100644 index 0000000..eef0dd6 --- /dev/null +++ b/C++/cubeSwitch/cubeSwitch.cpp @@ -0,0 +1,95 @@ +// Your Name +// Date: +// Program Title: +// Program Description: + +#include +#include +#include +#include + +using namespace std; + +// Named constants + +int main() +{ + + // Variable declaration + float sideLength; + int choice; + + //Program title and description for the user + + cout << "MENU TEMPLATE with SWITCH CASE" << endl << endl; + + // User input + + cout << "Choose the corresponding number for what task you want to complete." << endl; + cout << "1 - perimeter of one side " << endl; + cout << "2 - surface area of one side" << endl; + cout << "3 - surface area of the entire box" << endl; + cout << "4 - volume of the box." << endl; + cout << "Enter selected number here: "; + cin >> choice; + + // Calculations + + // Output to the screen + + switch (choice) + { + case 1: + + cout << "Perform task #1 : Perimeter of one side" << endl; + + //Input + cout << "Enter the side length: "; + cin >> sideLength; + + //Calculate and Output + cout << "Side Perimeter Is: " << 4*sideLength << " Cubed Inches \n"; + break; + + case 2: + cout << "Perform task #2 : Surface area of one side" << endl; + + //Input + cout << "Enter the side length: "; + cin >> sideLength; + + //Calculate and Output + cout << "Side Area Is: " << pow(sideLength, 2) << " Cubed Inches \n"; + break; + + case 3: + cout << "Perform task #3 : Surface area of the entire box" << endl; + + //Input + cout << "Enter the side length: "; + cin >> sideLength; + + //Calculate and Output + cout << "Cube Surface Area Is: " << 6*pow(sideLength, 2) << " Cubed Inches \n"; + break; + + case 4: + cout << "Perform task #4 : Volume of the box" << endl; + + //Input + cout << "Enter the side length: "; + cin >> sideLength; + + //Calculate and Output + cout << "Cube Volume Is: " << pow(sideLength, 3) << " Cubed Inches \n"; + + return 0; + + + break; + + default: + cout << "Input error; program is terminating" << endl; + } + return 0; +} -- cgit v1.2.3