A basic Calculator

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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include <iostream>

#include <iostream>

using namespace std;




class burito{

public:
    void multiply2(){


    burito burito2;
    burito2.bacon();
    };
    void division2(){
    burito burito2;
    burito2.division();
    }



private:
    void bacon(){
    int a;
    int b;
    int sum;


    cout << "Enter a number\n";
    cin >> a;
    cout << "Enter the multiplier\n";
    cin >> b;
    sum = a*b;
    cout << "the sum is " << sum <<endl;
    };


    int division(){
      int a;
    int b;
    int sum;


    cout << "Enter a number\n";
    cin >> a;
    cout << "Enter the number to Divide it by\n";
    cin >> b;
    sum = a/b;
    cout << "the answer is " << sum <<endl;
std::cin.get();
};

};


class Joseph{

 public://make these things private, then use "proxy" of public. it make it harde to break!
    void addition2(){
    Joseph Joseph3;
    Joseph3.addition();


    };

     void subtraction2(){
     Joseph joseph4;
     joseph4.subtraction();

     };






      private:
      void addition(){
          int a;
          int b;
          int sum;
           cout <<"Enter a number\n";
            cin >> a;
            cout << "enter second number\n";
            cin >> b;
      sum = a +b;
      cout << "the sum is " << sum << endl;

      }
       void subtraction(){
           int a;
           int b;
           int sum;
       cout << "Enter 1st number\n";
      cin >> a;
       cout << "entet 2nd number!\n";
       cin >> b;
       sum = a - b;
       cout << "the diffrence is " << sum << endl;

       }


};



int main()
{
    int a;
    int b;
    int c = 1;
    while(c<10){
//    ^ keeps running
    Joseph Josephg;

    cout << "Enter 1 for addition 2 for subtration 3 for Multiplicatoin and 4 for Division,\n then press enter\n";
    cin >> a;

    if (a == 1){
    Josephg.addition2();//This is pulling the faction from another class!
    std::cin.get();
    }

    if(a==2){



    Josephg.subtraction2();
    std::cin.get();
    }
    if(a==3){
        burito burito2;
        burito2.multiply2();
    }
    if(a==4){
            burito burito2;
            burito2.division2();

    }
    if(a>=5){
        cout << "Invalid Number, Try agian\n";


    }
std::cin.get();
cout << "\n\n\n\n\n";
   c++;


    }
cout << "calculator tired, going to sleep\nrestart to continue!";
}


Would that be a good basic calculator for command prompt? I am really just looking for any pointers, and anything I am doing wrong.(Besides The reason the addition and subtraction are separate from the multiplication and division is that I wrote them at different times and wasn't paying attention)

Thank you!
Would that be a good basic calculator for command prompt?
It depends on your definition of 'good'. If it does what you want then it is good.

I wouldn't take a look at your source due to the nonsense names like 'burito' or 'Joseph' which do not tell what's the intention behind them. Plus using class without member variables isn't useful either.
Topic archived. No new replies allowed.