do..while function

please help me!! :( how to do this??
C++ program (using do..while) to simulate a hand-held electronic calculator by displaying a menu as below

ELECTRONIC CALCULATOR

SELECT OPERATION :

1. Addition (+)
2. Subtraction (-)
3. Multiplication (*)
4. Division (/)
5. Modular (%)
6. Power (exponentiation)
7. Exit

Your Selection : _____

the program should be able to execute the following:

Read two numbers and read the operation by selecting the menu until selection 7 entered.
Then send the numbers to the function.
Calculate the result based on selection, then pass the result to the calling function
Display the two numbers, type of operation and the result for each operation


anybody have idea about this?? this is my assignment but i have no idea at all..
thanks..:)
This might not be perfect, but it's something like what you asked about. I hope you can at least learn from it.
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
#include <iostream>
#include <cmath>

int addNums(int, int);
int subNums(int, int);
int mltNums(int, int);
float divNums(int, int);
int modNums(int, int);
double expNums(int, int);

int main() {
  int num1,
        num2;
  int command;
  cout << "Enter the first number: ";
  cin >> num1;
  cout << "Enter the second number: ";
  cin >> num2;
  cout << endl;
  do {
    cout << "\nSELECT OPERATION\n";
    cout << "\n1.Addition (+)\n";
    cout << "2.Subtraction (-)\n";
    cout << "3.Multiplication (*)\n";
    cout << "4.Division (/)\n";
    cout << "5.Modular (%)\n";
    cout << "6.Power (exponentiation)\n";
    cout << "7.Exit\n\n";
    cout << "Your selection: ";
    cin >> command;
    cout << endl;
    switch (command) {
      case 1:
        cout << num1 << " + " << num2 << " = " << addNums(num1, num2) << endl;
        break;
      case 2:
        cout << num1 << " - " << num2 << " = " << subNums(num1, num2) << endl;
        break;
      case 3:
        cout << num1 << " * " << num2 << " = " << mltNums(num1, num2) << endl;
        break;
      case 4:
        cout << num1 << " / " << num2 << " = ";
        if (num2!=0) cout << divNums(num1, num2) << endl;
        else cout << "(division by 0 not allowed!)\n";
        break;
      case 5:
        cout << num1 << " % " << num2 << " = ";
        if (num2!=0) cout << modNums(num1, num2) << endl;
        else cout << "(division by 0 not allowed!)\n";
        break;
      case 6:
        cout << num1 << "^" << num2 << " = " << expNums(num1, num2) << endl;
        break;
    }
  } while (command!=7);
}

int addNums(int num1, int num2) {
  return num1+num2;
}

int subNums(int num1, int num2) {
  return num1-num2;
}

int mltNums(int num1, int num2) {
  return num1*num2;
}

float divNums(int num1, int num2) {
  return num1/num2;
}

int modNums(int num1, int num2) {
  return num1%num2;
}

double expNums(int num1, int num2) {
  return pow(num1, num2);
}
Topic archived. No new replies allowed.