ATM code showing arrayIndexOutofBound runtime error

import java.io.;
import java.lang.
;
class atm
{
public static void main(String[] args)

{

double x=0.0,z=0.0,y=0.0;
    
    x=Double.parseDouble((args[0]));
    
    y=Double.parseDouble((args[1]));
   
  if((x%5)==0 && x<=y)
 {

  	if(x>0 && x<=2000 && y>=0 && y<=2000.00 )
  	{  	
  		z=y-(double)x-0.5; 
  		if(z>=0)
  		System.out.println(z);
  		else
  		System.out.println(y);
    }	
  }
  
  else
  {
  	System.out.println(y);
  }

}
}

Problem in your program is that you expect that you will input as parameters.

You have to read parameters from standard input. Do it almost same way you did in TEST problem :wink:

You can read more about input reading in Java.

1 Like