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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130

#include<iostream>
#include<cmath>
using namespace std;
// Function Prototypes 
void print_menu();
float get_value();
float divide(float,float);
float multiply(float,float);
float vrc(float,float);
float vs(float);
float cube(float);
// Main 
int main()
{
float operand1, operand2, answer;
int choice, valid_choice;
do{
print_menu();
cin >> choice;
valid_choice = 1; // assume choice is valid
switch(choice){
case 0:
break;
case 1:
operand1 = get_value();
operand2 = get_value();
answer = operand1 + operand2;
break;
case 2:
operand1 = get_value();
operand2 = get_value();
answer = operand1  operand2;
break;
case 3:
operand1 = get_value();
operand2 = get_value();
answer = multiply(operand1,operand2);
break;
case 4:
operand1 = get_value();
operand2 = get_value();
answer = divide(operand1,operand2);
break;
case 5:
operand1 = get_value();
operand2 = get_value();
answer = vrc(operand1, operand2);
break;
case 6:
operand1 = get_value();
answer = vs(operand1);
break;
case 7:
operand1 = get_value();
answer = cube(operand1);
break;
case 8:
cout << "Enter how many variables up to 100 : ";
operand1 = get_value();
case 9:
cout << "Enter how many variables up to 100 : ";
default:
valid_choice = 0;
cout << "Invalid Choice." << endl;
}
if(valid_choice){
cout << endl << "Answer = " << answer << endl;
}
}while(choice != 0);
return 0;
}
// Functions 
float divide(float dividend, float divisor){
if(divisor == 0)
return 0; // avoids divide by zero errors
else
return (dividend/divisor);
}
float multiply(float multi, float multiplier){
return (multi*multiplier);
}
float vrc(float r, float h) {
return (3.14159 * (pow(r,2)) * h);
}
float vs(float r) {
return (divide(4,3)) * (3.14159) * (pow(r,3));
}
float cube(float s) {
return (pow(s,3));
}
float get_value(){
float temp_value;
cout << "Enter a value: ";
cin >> temp_value;
return temp_value;
}
void print_menu(){
cout << endl;
cout << "Add (1)" << endl;
cout << "Subtract (2)" << endl;
cout << "Multiply (3)" << endl;
cout << "Divide (4)" << endl;
cout << "Volume of a Right Cylinder (5)" << endl;
cout << "Volume of a Sphere (6)" << endl;
cout << "Volume of a Cube (7)" << endl;
cout << "Average (8)" << endl;
cout << "Standard Deviation (9)" << endl;
cout << "Exit (0)" << endl;
cout << "Enter you choice: ";
}
