This is first attempt on the codeChef. Can someone please help me to understand what is wrong with my code here? It seems to be working fine on my IDE and on Custom Input. Kindly suggest.
Code:
class Main{
float x = 0;
int y = 0, calc = 0;
int max = 1999;
int min = 1;
int bank_amt = (int) ((Math.random() * ((max-min)+1)) + min);
System.out.println("Input: ");
Scanner in = new Scanner(System.in);
int withdrawal_amt =in.nextInt();
System.out.print(bank_amt + "\n");
if((withdrawal_amt > 1) && (withdrawal_amt < 2000)) {
calc = withdrawal_amt % 5;
if(calc == 0) {
y = bank_amt - withdrawal_amt;
x = (float) (y - 0.50);
}
else {
x = bank_amt;
}
System.out.println("Output: " +x);
}else {
System.out.println("Output: " +bank_amt);
}