+ 1

HELP! If statement ignored

#include <iostream> using namespace std; int main () { double weight, age, water, n_weight; cout << "How much do you weigh (in pounds)?" << endl; cin >> weight; cout << "How old are you? " << endl; cin >> age; n_weight = weight / 2.2; if (age <= 29) n_weight*40; if (age >= 30 && age <= 54) n_weight*35; if (age >= 55) n_weight*30; water = n_weight/28.3; cout << water; return 0; } why is it ignored?

30th Jan 2018, 11:13 PM
King
King - avatar
4 ответов
+ 2
post the link to the code so we can run it
30th Jan 2018, 11:15 PM
Jeremy
Jeremy - avatar
+ 1
You are not checking for partial values for your ages when you declared them as double, for example 29.5 would not fall into any of the if statement blocks. Also, once inside the if statement blocks you do not assign the result of the multiplication to anything. https://code.sololearn.com/c4D4ppNz6hv7/?ref=app
31st Jan 2018, 1:14 AM
Jesse Bayliss
Jesse Bayliss - avatar
0
https://code.sololearn.com/ctB0fAU9YWTq/?ref=app
30th Jan 2018, 11:27 PM
King
King - avatar
0
everything works fine for me
31st Jan 2018, 12:07 AM
Jeremy
Jeremy - avatar