Given two int values, print whichever value is larger. However if the two values have the same remainder when divided by 5, then the print the smaller value. However, in all cases, if the two values are the same, print 0.
This is what I have so far:
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int x = scan.nextInt();
int y = scan.nextInt();
if(x > y || (x%5 == y%5 && y > x))
{
System.out.println(x);
}
else if (y > x || (x%5 == y%5 && x > y ))
{
System.out.println(y);
}
else if(x == y)
{
System.out.println("0");
}
}
My score was 79/100 when I sent it to an online judge
What seems to be the problem?
Scanner
input. That might warrant lower points. \$\endgroup\$