Help building a calculator

Hey, so now today our computer teacher gave us a program to write which has to act as a calculator, don't know how's that possible so I used 2 addition values, 2 subtraction values, 2 multiplication values and 2 division values, the program also has to use cascading so here's what I made :
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
using namespace std;
	void main()
{float add1, add2, add3, sub1, sub2, sub3, mty1, mty2, mty3, div1, div2, div3;
cout << "Add values here:" << "\t\t" << "\n" << "Subtract values here" << "\t\t" << "\n" << "Multiply values here" << "\t\t" << "\n" << "Divide values here" << "\t\t" << "\n";
cin >> add1 >> add2 >> sub1 >> sub2 >> mty1 >> mty2 >> div1 >> div2;
add3 = add1+add2;
sub3 = sub1-sub2;
mty3 = mty1*mty2;
div3 = div1/div2;
cout << add1 << "\n" << sub3 << "\n" << mty3 << "\n" << div3 << "\n";
system("pause");
}


The calculator works fine, the problem with it is, The enter values for addition lines are useless as the program doesn't inputs the values after the "Addition values here" instead it prints all the cout lines and then the input, I could solve this problem with multiple cout lines but we're not allowed to do that, so I was thinking may be you guys could help me out with the problem?
Why not ask what the user wants? Like type 1 for addition, 2 for subtraction, 3 for ...
Tha a good idea but it will require if-then-else statements which I haven't been taught yet, so please try to search for a solution
Try to break the cin statement into pieces.
Like:
1
2
3
4
cout << "Addition 1:\n";
cin >> add1;
cout << "Addition 2:\n";
cin >> add2;


Then see if the error persists.

If it does, then try putting an cin.ignore() after every one that doesn't work.

BTW you shouldn't be using void main (). It isn't standard C++
Rather it should return an int with return 0; at the end.


Er...Nisheeth thanks for the help, but I did mention at first that we have to make this program using cascades, and so I can't break the cin and cout commands into pieces, if I was allowed to do I would've done so, btw yeah I know it's int, but well the void one goes ok with the visual 2010 compiler.
if-then-else logic...

if(option 1){
do this......
}
else if(option 2){
do something else....
}
else{
last resort....
}
So you want that the program to have the following output:


Add values here:
2
3
Subtract values here
5
6
...


I don't think there is a way to do that without using separate cin and cout commands
Ok thanks, I wanted to use the if-then-else statements anyways, but I guess my teacher won't appreciate it, out of luck this time.
as long as it gets the job done...
Topic archived. No new replies allowed.