### A basic Calculator

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157`` ``````#include #include 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 <> a; cout << "Enter the number to Divide it by\n"; cin >> b; sum = a/b; cout << "the answer is " << sum <> 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.