+ 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)

11th Sep 2017, 3:02 PM
Sampson Joshua (Jozy)
Sampson Joshua (Jozy) - avatar
4 Answers
+ 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.
11th Sep 2017, 3:12 PM
Tashi N
Tashi N - avatar
+ 7
OK. try your date of birth with negative e.g -1997
11th Sep 2017, 3:08 PM
Sampson Joshua (Jozy)
Sampson Joshua (Jozy) - avatar
+ 6
am happy it's fixed thanks guys @Tashi N you rock I give you 5ā­ā­ā­ā­šŸŒŸ
11th Sep 2017, 5:24 PM
Sampson Joshua (Jozy)
Sampson Joshua (Jozy) - avatar
+ 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
11th Sep 2017, 3:06 PM
Benjamin Villalobos
Benjamin Villalobos - avatar