«Я пытаюсь сделать банковское приложение, которое обновляет баланс каждый раз, когда вы вводите депозит или выходите. Я получил меню и все остальное, чтобы работать хорошо, но при распечатке окончательного баланса , баланс всегда остается в 5000.00. Где я ошибся? "Не удается получить двойной (баланс) для обновления
double balance = 5000.00;
switch(menu){
case 'd': case 'D':
double deposit = depositFunds(balance);
break;
case 'w': case 'W':
double withdrawl = withdrawFunds(balance);
break;
case 'b': case 'B':
checkBalance(accountNumber, balance);
break;
}//end of switch
}//end of main
public static double depositFunds(double balance){
Scanner input = new Scanner(System.in);
System.out.print("\nEnter the amount of the deposit: ");
double deposit = input.nextInt();
double currentBalance = (balance + deposit);
return currentBalance;
}//end of depositFunds
public static double withdrawFunds (double balance){
Scanner input = new Scanner(System.in);
double currentBalance;
System.out.print("\nEnter the amount of the withdrawal: ");
double withdrawal = input.nextInt();
currentBalance = (balance - withdrawal);
return currentBalance;
}//end of withdrawFunds
//Display the balance
public static void checkBalance(int accountNumber, double balance){
System.out.printf("\nAccount Number: %d has a current balance of: %.2f\n" , accountNumber , balance);
}//end of checkBalance
вам нужно назначить вычисленные значения для "баланса". вы не меняете его – Reek
Я собираюсь снять отрицательную сумму;) – StaticShadow
Что вы имеете в виду присвоить вычисленным значениям «баланс»? Где я могу это сделать? –