### Need Some Help (With a simple calculator)

I've been having trouble with my calculator its my first program.I keep getting an error at the last line of my code and can't find out why.Here is the code

#include <iostream>

using namespace std;

public:
int a;
int b;
int sum;

cin >> a;

cout << "+";

cin >> b;

sum = a + b;
cout << sum << endl;

return 0;
}
};
class Subtraction{
public:
int SUB(){
int a;
int b;
int sum;

cin >> a;

cout << "-";

sum = a - b;
cout << sum << endl;

return 0;
)
};
class Multipcation{
public:
int MULTI(){
int a;
int b;
int sum;

cin >> a;

cout << "*";

cin >> b;

cin << sum = a * b;
cout << sum << endl;

return 0;
}
};
int main()
{
int x;
int a;
int b;
int anwser;

Subtraction SUB;

Multiplcation MULTI;

cout << "What Kind Of Question Is This" << endl;
cin >> x;

if(x==1){
cout << "Test Worked" << endl;
}
return 0;
}

I keep getting an error on the very last line with the }. Thx
Btw the way the code isn't finsihed just stuck on this part.
One error I see is different names.
 ``1234567891011121314151617181920`` ``````class Multipcation{ // See spelling public: int MULTI(){ int a; int b; int sum; cout << "Ready" << endl; cin >> a; cout << "*"; cin >> b; cin << sum = a * b; cout << sum << endl; return 0; } };``````

`Multiplcation MULTI; // Different spelling to above `
closed account (3qX21hU5)
Hey there first off I would like to reccomend you use codetags whenever you post code to the forums (Hint: the <> off to the right when replying) it makes the code much easier to read. Now on to the problems

First It is always a good idea to get familiar with compiler errors for whatever compiler you are using. Try writing simple code that you know works and compiles and then start removing things and creating errors to see what different error messages you get. This way you will have a better idea what the errors mean.

Also Always work from the first error down. Like if there is a error on line 4 and line 8 and line 10. Always start on the line 4 because alot of the time the other errors are caused because of the first ones.

1) Line 41
 ``12345`` ``````sum = a - b; cout << sum << endl; return 0; )``````

Notice the ")". This is not suppose to be here delete it.

2) Line 56

`cin << sum = a * b;`

Not sure why you are using `cin` here. If you are trying to assign a*b to sum you just need to do this `sum = a * b;`

3) Your mispelling the classes. Look at how the classes are spelled in your definitions and when you call them in main. Always make sure you have the correct spelling and it is case sensitive.

4) Your subtraction class is missing a } look it over and see where you are missing it.

5) You have a lot of variables declared that you are not using. If you are not going to use these delete them.

Hope this help alittle
Thank you help me a lot. This was my first try at making a bigger code then my
only addition calculator i'll try to fix it and check my code better.
Topic archived. No new replies allowed.