HS08TEST wrong answer??? y?

import java.text.DecimalFormat;
import java.util.Scanner;
class mm
{
public static void main(String args[])
{

  int w;
  Double bal;
  Scanner in=new Scanner(System.in);
  w=in.nextInt();
    bal=in.nextDouble(); 
  
  if(w<=2000&&w>0&&w%5==0&&w<=bal)
  {
	  
    if(bal<=2000 && bal>=0)
     bal=(bal-w)-0.5;
   
  
  }
  DecimalFormat df = new DecimalFormat("#.00");
 
  System.out.println( df.format(bal));
  }
}

Check your code for this output-

Input
120 120.00
Your Output
-.50
Expected Output
120.00

She should have enough money for withdraw+bank charges, so this condition w<=bal is particularly incorrect.

1 Like