+ 2

Output of the code is note as expected. Can anyone help?

https://code.sololearn.com/c21eQh2k6q6E/?ref=app

13th May 2019, 1:10 PM
Aman Porwal
6 Antworten
+ 1
Line 21, 23: you are comparing integer variable with another undefined variable I feel you are trying to compare variable with string instead of another variable i.e if (sex == "male") If so, you need to change the declaration of variable from int to string at line no. 6 And finally it's not ok to declare a variable as void. A more appropriate data type here would be float as you are doing decimal point operations Final note Line no.6 string sex, status; int salary; Line 27 ,38 float tax
13th May 2019, 2:53 PM
‎ ‏‏‎Anonymous Guy
+ 6
1) You do not need endl for cin 2) employed is not a defined variable. You used int, so maybe employed could mean 1?
13th May 2019, 1:15 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 6
All of them are now set at 0
13th May 2019, 2:44 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
male is also not defined anywhere. From line 27 you wrote cout >> instead of cout << as you should.
13th May 2019, 1:18 PM
HonFu
HonFu - avatar
+ 2
Line 9, 13, 17: Remove endl Endl is used after printing not after taking input Line no. 21, 27, 38, 44: replace >> with << after cout
13th May 2019, 2:25 PM
‎ ‏‏‎Anonymous Guy
0
Also keep in mind that std::string's == operator is case sensitive, ie "male" != "Male". You can either use stricmp: stricmp (sex.c_str (), "male") == 0 Or you can convert the input string to lowercase using tolower before comparing: for (auto& c : sex) c = tolower (c); Also of note, cin's >> operator doesn't play well with spaces. Consider using std::getline instead, like so: cout << "Name: "; getline (cin, Name); cout << "Entered " << Name << endl; Good luck <3
14th May 2019, 7:26 PM
Nemo