Java If Else Hackerrank Solution