I am new to c++ and would really kindly need help with this code...
#include <iostream>
using namespace std;
int main() {
double plus1,minus1,multi1,division1;
double plus2,minus2,multi2,division2;
double countP;
double countM;
double countMM;
double countD;
int in;
std::cout << " What do you want to do\n1.Addition\n2.Substraction\n3.Multiplication\n4.Division\n";
cin >> in;
if(in = 1) {
cout << " First value\n";
cin >> plus1;
cout << " Second value\n";
cin >> plus2;
countP = plus1 + plus2;
cout << " The total value became " << countP << " happy now?\n";
}
else if(in = 2) {
cout << " First value\n";
cin >> minus1;
cout << " Second value\n";
cin >> minus2;
countM = minus1 - minus2;
cout << " The total value became " << countM << " happy now?\n";
}
else if(in = 3) {
cout << " First value\n";
cin >> multi1;
cout << " Second value\n";
cin >> multi2;
countMM = multi1 * multi2;
cout << " The total value became " << countMM << " happy now?\n";
}
else if(in = 4) {
cout << " First value\n";
cin >> division1;
cout << " Second value\n";
cin >> division2;
countD = division1 / division2;
cout << " The total value became " << countD << " happy now?\n";
}
return 0;
}
Whenever I do subtraction it ends up adding the two values I mean come on. value one - value two does not equal value one + value two...Anyway to do it the "right" way?


Sign In
Create Account



Back to top









