Hello, i have a program where inputed numbers must be in interval from 2.0 to 5.0. if it's true, second if block must run forward, if not true, further blocks must be ignored, and program show else. Now when program run, i'm always get else.
(pirmas || antras || trecias) >= 2.0This is not doing what you think.
first (pirmas || antras || trecias) would be calculated with result bool which will be converted in either 0 or 1 which is less than 2, so your condition is always false.
Correct way: ((primas >= 2.0) || (antras >= 2.0) || (treacias >=2.0)) && //...
Also you can run into floating point comparsion issues here.
i'm change program like you say: <code>if ((pirmas >= 2.0) || (antras >= 2.0) || (trecias >= 2.0) && (pirmas <= 5.0) || (antras <= 5.0) || (trecias <= 5.0))</code> but now if i write incorect number like 8.2 or something else, program still carried forward, and not show else statement
here's my task:
Write a program that asks for the name of a shooter and the date and vault
heights (in meters) of the athlete s three best vaults. It should then report, in order of height (best rst), the date on which vault was made and it height.
Input Validation: Only accept values between 2.0 and 5.0 for the heights.
Your problem that now your if statement requires at least one of your variables to be equal or larger that 2.0 and at least one to be equal or lesser that 8.0.
You want all of them to be >=2 and <=8. So change all logical or (||) to and (&&)