The compiler doesn't accept my solution. [reff.№: HS08TEST]

class Codechef
{
public static void main (String[] args)
{
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
double balance = scanner.nextDouble();
double result;

    if (n % 5 == 0 && n < balance){ result =(balance - n) - 0.5;
        System.out.println(result);}
    if (n % 5 != 0 && n+0.5<= balance){
        System.out.println(balance);}
    else if (n>balance || n+0.5>balance){
        System.out.println("Insufficient transaction");}
}

}

After reading the question some,
Points to Note (refer problem for X and Y notation):

  1. If X is not divisible by 5 or X + 0.5 is greater than Y, we simply output Y.
  2. Else, we do arithmetic: Y = Y - (X + 0.5) and output Y.
  3. Output should be up to 2 decimal places, so format accordingly.

We never output “Insufficient transaction”.

1 Like

TY for clarifying!
SOLVED.

1 Like