0
Why is my code not outputting correctly? 🤷🏼♂️
This is a pretty simple code where you enter your systolic and diastolic blood pressures and whether you are in a healthy range is outputted. However, if you enter 140 for systolic and 80 for diastolic, that is stage 2 hypertension which is what is in the code but the output is stage 1. Any ideas why? Any help is much appreciated!! https://code.sololearn.com/c0J1Zop5401S/?ref=app
3 Respuestas
+ 1
Stage 1 the condition is 120<=S<=129 OR 80<=D<=89.
That is, if either S or D matches, the condition will be true.
S = 140 doesn't match, but D = 80 matches.
If you want the condition is false, use &&
0
Makes sense thanks!
0
I found the answer. I DO want to use OR because only one of the conditions has to be true to qualify for stage 1 or 2, etc. But if I reverse the order of the else if statements it checks stage 2 before stage 1 and it comes out right.