+ 1

Can anyone help me with this code?

I'm having trouble with an "initializer" and i would gladly appreciate your help https://code.sololearn.com/cXHWdDMpgeW4/?ref=app

28th Jul 2017, 4:17 PM
BwD//Felix Janetzki
BwD//Felix Janetzki - avatar
8 Réponses
+ 1
ok there are some thing that don't work 1 - a switch is very useful, but if you said you don't like it no problems, everyone can code as they like 2 - in your code there is int A; //Mode int input; so A and input are declared as int type (integer) so you are saying that A and input will be numbers. But if the user type a string (as you want, i've understood that you want the user type "input" as A), the program doesn't understand, because he was waiting for A, that he believed was a number, but he finds a string, so he is a little bit confused and gives A the value 0. So firstly you need to declare A as a string string A instead of int A then in the if you need to write if(A=="input") because you want to compare A with a string ("input" between "") input is not a variable, is a string you want to compare A with 3 - Remember that if you want to make an user-friendly and understandable programs you should let the user know what commands he has to use. You can firstly of all make a cout<< with the description of the commands, their function and what the user has to type. Example: cout << "Hi, you can type: input: blablabla...; experimental: blablabla"; cin >> A; cout <<"Now you can type add:... ; sub:... ;"; cin >> B; and so on...
28th Jul 2017, 7:03 PM
Matte
Matte - avatar
+ 2
Thanks alot to everyone! My code's beginning to work!!! Thx alot!!
28th Jul 2017, 7:28 PM
BwD//Felix Janetzki
BwD//Felix Janetzki - avatar
+ 1
do you receive this error? "expected initializer before '>>' token"
28th Jul 2017, 4:49 PM
Matte
Matte - avatar
+ 1
yeah i do
28th Jul 2017, 6:22 PM
BwD//Felix Janetzki
BwD//Felix Janetzki - avatar
+ 1
nah, would you mind to take a look?
28th Jul 2017, 6:28 PM
BwD//Felix Janetzki
BwD//Felix Janetzki - avatar
0
In your code: int <== Error here. remove this line! //RECEIVE DATA STREAMS cin >> A; etc....
28th Jul 2017, 5:28 PM
Ettienne Gilbert
Ettienne Gilbert - avatar
0
does it work now?
28th Jul 2017, 6:25 PM
Matte
Matte - avatar
0
the problem with A and "input" is the same with B and "add", "sub",... try to fix your code on your own, anyway if you don't succeed, this should work remember that if you leave cin>>A; cin>>B; cin>>C; cin>>D; when you write the input you must write different lines like this input add 5 6 https://code.sololearn.com/ceeqN7IlFcjp/?ref=app
28th Jul 2017, 7:08 PM
Matte
Matte - avatar