#include <cstdlib>
#include <iostream>
usingnamespace std;
int addition(int num1, int num2)
{
return num1 + num2;
}
int subtraction(int num1, int num2)
{
return num1 - num2;
}
int multiplication(int num1, int num2)
{
return num1 * num2;
}
int division(int num1, int num2)
{
return num1 / num2;
}
int main()
{
int number1;
int number2;
//Addition
cout << "You are adding. Enter the first number you would like to add. \n Number 1: ";
cin >>number1;
cout << " Enter the second number. \n Number 2: ";
cin >> number2;
cout << " The answer is: " << addition(number1, number2) << endl;
//Subtraction
cout << "You are subtracting. Enter the first number you would like to subtract. \n Number 1: ";
cin >> number1;
cout << "Enter the second number. \n Number 2: ";
cin >> number2;
cout << " The answer is: " <<subtraction(number1, number2) << endl;
//Multiplication
cout << "You are multiplying. Enter the first number you wish to multiply. \n Number 1: ";
cin >> number1;
cout <<" Enter the second number. \n Number 2: ";
cin >> number2;
cout << " The answer is: " << multiplication(number1, number2) << endl;
//Division
cout << "You are dividing. Enter the first number you wish to divide. \n Number 1: ";
cin >> number1;
cout << " Enter the second number you wish to divide. \n Number 2: ";
cin >> number2;
cout << " The answer is: " << division(number1, number2) << endl;
//End program
}
I want to implement a menu that would allow a user to input 'a' for addition, 's' for subtraction, 'm' for multiplication, and 'd' for division, and then press enter and the program will go to the corresponding section (addition, subtraction, multiplication, division). How would I add such a menu into this code?
Thanks in advance.