+ 9
Pls run the code attached here my question is in the description..thanks
https://code.sololearn.com/cilUd7pmN1tA/?ref=app In the code👆👆👆👆 I want it to print users age when the supply their year of birth and that works fine, also I have that no negative year of birth e.g( -1993) should be accepted, but it still prints out the age,i have tried how to make it not give out the age with a negative year of birth but couldn't , please someone should help am new to java (please run the code you will see what I am talking about)
4 Réponses
+ 8
Your if statement: if (year <=-1) is OK, but you need to add else to the next statement, so that this path is only executed, if the first condition is false.
Or throw an Exception if your year check is true.
+ 7
OK. try your date of birth with negative e.g -1997
+ 6
am happy it's fixed thanks guys @Tashi N you rock I give you 5⭐⭐⭐⭐🌟
+ 1
It works ok I put my birth year in there and it told me my right age I wish I understood what you meant as I'm very new to coding