我真笨。
import java.util.Scanner;
public class ATM {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double withdraw = scanner.nextDouble();
double balance = scanner.nextDouble();
int withdraw = 0; int balance;
if (withdraw % 5 == 0 && withdraw<(balance-.5)) {
balance = balance - (withdraw + .5);
System.out.println(balance);
}
else {
System.out.println(balance);
}}}
我正在努力使余额被提款金额减去,同时产生 0.50 美元的费用。不幸的是,它一直只减去 $.50 而不减去提款。提前致谢。
固定代码
import java.util.Scanner;
public class ATM {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double withdraw = scanner.nextDouble();
double balance = scanner.nextDouble();
if (withdraw % 5 == 0 && withdraw<(balance-.5)) {
balance -= (withdraw + .5);
System.out.println(balance);
}
else {
System.out.println(balance);
}}}