Error while solving a java problem which runs well on my computer.

Here is the code.
Works well on my computer
import java.util.Scanner;
public class Main{
public static void main(String args[]){
double initialamount=2000.00;
System.out.println(“Your intial amount is”+initialamount);
Scanner scannerforuserinput= new Scanner(System.in);
System.out.println(“Enter the amount to be withdrawn :”);
int amounttobeenteredbyuser= scannerforuserinput.nextInt();
if(amounttobeenteredbyuser<2000.00 && amounttobeenteredbyuser>0 && amounttobeenteredbyuser%5==0){
System.out.println(“Valid Entry”);
atm(amounttobeenteredbyuser);
}
else if(amounttobeenteredbyuser>2000.00) {
System.out.println("Your balance is "+initialamount);
System.out.println(“Amount entered is exceeding the balance amount.”);

}
else { System.out.println(“Invalid Entry.Your amount should be a multiple of 5.”);
}

}public static void atm(int amounttobewithdrawn){
double initialamount=2000;
System.out.println(“Your intial amount is”+initialamount);
double newamount= initialamount- amounttobewithdrawn - 0.50;
System.out.println(“Your final amount”+newamount);
}}

Welcome, @unbeatenseven !

@thor1234 wrote an awesome guide to asking for help here. I suggest you check it out:

Anyway, for your code, I suspect it’s failing in part because of things like…
System.out.println(“Enter the amount to be withdrawn :”);

If you’re trying to solve Codechef’s ATM problem, it specifies exactly what the output should look like.

Good luck, I hope this helps!

2 Likes