Please help. I did an exercise that was accepted on Run option but then its marked as wrong answer… I tried all expected outputs and it’s exectly the same, I don’t understand.
The exercise name is ATM, and code is: HS08TEST
The code I have is as follows if you don’t mind to check:
private static final DecimalFormat TWO_DECIMAL = new DecimalFormat(“0.00”);
private static final int MIN_WITHDRAW = 0;
private static final int MAX_WITHDRAW = 2000;
private static final float TAX = 0.5f;
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double withdraw, currentBalance;
if (input.hasNext()) {
withdraw = input.nextDouble();
boolean isMultipleOf5 = withdraw % 5 == 0;
if (withdraw <= MIN_WITHDRAW || withdraw > MAX_WITHDRAW) {
//System.out.println("Invalid: amount of cash which Pooja wishes to withdraw.\n");
}
currentBalance = input.nextDouble();
if (withdraw < MIN_WITHDRAW || withdraw > MAX_WITHDRAW) {
//System.out.println("Invalid: Pooja's initial account balance.\n");
}
if (withdraw <= currentBalance + TAX && (isMultipleOf5)) {
currentBalance -= withdraw + TAX;
System.out.printf("%.2f",currentBalance);
} else if (withdraw > currentBalance + TAX || !(isMultipleOf5)) {
System.out.println(TWO_DECIMAL.format(currentBalance));
}
}
}
Let me thank you in advance for your time if you even bothered to even try and help