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
|
#include <iostream>
using namespace std;
void ADD(const int &num1, const int &num2, float &SUM);
void SUBTRACT(const int &num1, const int &num2, float &Difference);
void MUTIPLY(const int &num1, const int &num2, float &PRODUCT);
int main()
{
int choice = 0;
int total = 0;
float a = 0, b = 0, c = 0;
int num = 0;
int num1, num2;//num1 and num2 go in main
//Menu Chooser
//Choose the type of loop you want to use to average this program
cin >> num1 >> num2;
cout << "OPERATIONS\n\n";
cout << "1 - ADD\n";
cout << "2 - SUBTRACT\n";
cout << "3 - MUTIPLY\n\n";
cout << "4 -Exit\n\n";
cout << "Choice: ";
cin >> choice;
// Demonstrates the switch statement.
//Pick a loop.
{
switch (choice)
{
case 1:
{
//ADDITION
ADD(num1, num2, a);
cout << "\You have chosen to ADD.";
cout << "\The sum is:" << a;
}
break;
case 2:
{
//SUBTRACTION
SUBTRACT(num1, num2, b);
cout << "\You have chosen to SUBTRACT.";
cout << "\The difference is:" << b;
}
break;
case 3:
{
//MUTIPLICATION
MUTIPLY(num1, num2, c);
cout << "\You have chosen to MUTIPLY.";
cout << "\The product is:" << c;
}
break;
case 4:
{
cout << "Goodbye";
}
break;
default:
{
cout << "You made an illegal choice.\n";
}
break;
}
}
return 0;
}
void ADD(const int &num1, const int &num2, float &SUM)
{
//SUM
SUM = num1 + num2;
}
void SUBTRACT(const int &num1, const int &num2, float &Difference)
// SUBTRACT
{
Difference = num1 - num2; //SUBTRACTION // to many equal signs
}
void MUTIPLY(const int &num1, const int &num2, float &PRODUCT)
{
//PRODUCT.
PRODUCT = num1 * num2;// to many equal signs
}
|