blob: eef0dd638e188d5a60fbe8788f2a0484c9e27c30 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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;
}
|