If else if ladder help with simple calculator program

Can someone help me modify this program using the if-else-if ladder so that instead of the program performing all 4 mathematical functions on two numbers, the user selects which mathematical function to perform, and to make sure the program has a menu for the user to use to select their choice. Also avoid having the computer perform a division by zero if the user attempts it by outputting a warning message in its place.

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


#include <iostream> 
using namespace std; 
int main ( ) 
{ 
/*Simple calculator*/ 
cout<<"Calculator\n "; 
cout<< "\n\n" ; 
double first, addition, subtraction, division, multiplication; 
first=60; 
double second=first/30; // this variable is dynamically initialized 
addition= first+second; 
subtraction= first-second; 
division= first/second; 
multiplication= first*second; 
cout<< "This program will add, subtract, divide, and multiply 60 and 2.\n" ; 
cout<< "\nHere is the sum\n" ; 
cout<<addition; 
cout<< "\nHere is the difference\n" ; 
cout<<subtraction; 
cout<< "\nHere is the division\n" ; 
cout<<division; 
cout<< "\nHere is the multiplication\n" ; 
cout<<multiplication; 
return 0; 
}
Topic archived. No new replies allowed.