#include <iostream>
#include <iostream>
usingnamespace 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)
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.