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
|
int main()
{
using namespace std;
enum MenuChoice
{
MENU_EXIT,
MENU_ADD,
MENU_SUBTRACT,
MENU_MULTIPLY,
MENU_DIVISION,
MENU_MODULO,
MENU_DEC_TO_BIN,
MENU_SQUARE_ROOT,
MENU_FACTOR,
MENU_FACTORIAL,
MENU_MEAN_MEDIAN_MODE_RANGE,
MENU_TIMES_TABLE,
MENU_FIBONACCI,
MENU_END // 13
};
const string strOperationSuccess = "\nFinished task, Repeating menu:\n";
const string strMenuDisplay = "What operation would you like to perform?: \n\n"
"1. Addition\n2. Subtraction\n3. Multiplication\n4. Division\n5. Modulo\n\n"
"6. Decimal to Binary\n7. Square Root\n8. Factor\n9. Factorial\n10. Mean, Median, Mode & Range\n"
"11. Times Table\n12. Fibonacci Sequence\n\n0. Exit\n";
unsigned short unMenuChoice = 0;
do
{
cout << strMenuDisplay << endl;
// get menu choice
if (!unMenuChoice)
cin >> unMenuChoice; // switch this to function call so we can error process
cout << endl;
// check for valid menu choice then call it
switch (unMenuChoice)
{
case MENU_EXIT:
cout << "Exiting..." << endl;
exit(0);
case MENU_ADD:
addition();
cout << strOperationSuccess << endl;
break;
case MENU_SUBTRACT:
subtraction();
cout << strOperationSuccess << endl;
break;
case MENU_MULTIPLY:
multiplication();
cout << strOperationSuccess << endl;
break;
case MENU_DIVISION:
division();
cout << strOperationSuccess << endl;
break;
case MENU_MODULO:
modulo();
cout << strOperationSuccess << endl;
break;
case MENU_SQUARE_ROOT:
squareRoot();
cout << strOperationSuccess << endl;
break;
case MENU_FACTOR:
factor();
cout << strOperationSuccess << endl;
break;
case MENU_FACTORIAL:
factorial();
cout << strOperationSuccess << endl;
break;
case MENU_MEAN_MEDIAN_MODE_RANGE:
meanMedianModeRange();
cout << strOperationSuccess << endl;
break;
case MENU_TIMES_TABLE:
timesTable();
cout << strOperationSuccess << endl;
break;
case MENU_FIBONACCI:
fibonacci();
cout << strOperationSuccess << endl;
break;
default:
cout << unMenuChoice << " is not a valid menu choice. Enter again.\n" << endl;
break;
}
// reset
unMenuChoice = 0;
} while (true);
return 0;
}
|