+ 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?
4 odpowiedzi
+ 2
post the link to the code so we can run it
+ 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
0
https://code.sololearn.com/ctB0fAU9YWTq/?ref=app
0
everything works fine for me