diff options
Diffstat (limited to 'C++/cubeSwitch')
-rw-r--r-- | C++/cubeSwitch/Ch 4 Cube program instructions.docx | bin | 0 -> 28802 bytes | |||
-rw-r--r-- | C++/cubeSwitch/cubeSwitch.cpp | 95 |
2 files changed, 95 insertions, 0 deletions
diff --git a/C++/cubeSwitch/Ch 4 Cube program instructions.docx b/C++/cubeSwitch/Ch 4 Cube program instructions.docx Binary files differnew file mode 100644 index 0000000..f59110d --- /dev/null +++ b/C++/cubeSwitch/Ch 4 Cube program instructions.docx 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 <iostream>
+#include <string>
+#include <iomanip>
+#include <cmath>
+
+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;
+}
|