/* Name: Simple Calculator Author: Thomas Cameron File: calculator.cpp Copyright (c) Thomas Cameron 2007. */ #include using namespace std; // create the dummys for the functions int Addition(int, int); int Subtraction(int, int); int Multiplication(int, int); int Division(int, int); // create the variables required int choice; // choice variable int a,b,c; // integer variables // create the main function class int main() { cout << "\n\nChoose: (1) Addition (2) Subtraction (3) Multiplication (4) Division\n\n"; cin >> choice; cin.ignore(); cout << "Enter the first number:\n"; cin >> a; cin.ignore(); cout << "\n\nEnter the second number:\n"; cin >> b; cin.ignore(); switch(choice) { case 1: c = Addition(a, b); break; case 2: c = Subtraction(a, b); break; case 3: c = Multiplication(a, b); case 4: c = Division(a, b); break; default: cout << "\n\nPlease choose a mathematical option.\n\n"; } cout << "\n\nYour answer is:\n" << c << "\n\n"; cout << "Please press any key to close the program."; cin.get(); return 0; } // create the addition function int Addition(int a, int b) { c = a + b; return c; } // create the subtraction function int Subtraction(int a, int b) { c = a - b; return c; } // create the multiplication function int Multiplication(int a, int b) { c = a * b; return c; } // create the division function int Division(int a, int b) { c = a / b; return c; }