Олимпиадный тренинг

Задача . 37100


Задача

Темы:
public class BankAccount
{
 private double balance;
 public BankAccount()
  { balance = 0; }
 public BankAccount(double acctBalance)
  { balance = acctBalance; }
 public void deposit(double amount)
  { balance += amount; }
 public void withdraw(double amount)
  { balance -= amount; }
 public double getBalance()
  { return balance; }
}
public class SavingsAccount extends BankAccount
{
 private double interestRate;
 public SavingsAccount()
  { /* implementation not shown */ }
 public SavingsAccount(double acctBalance, double rate)
  { /* implementation not shown */ }
 public void addInterest() //Add interest to balance
  { /* implementation not shown */ }
}
public class CheckingAccount extends BankAccount
{
 private static final double FEE = 2.0;
 private static final double MIN_BALANCE = 50.0;
 public CheckingAccount(double acctBalance)
  { /* implementation not shown */ }
/** FEE of $2 deducted if withdrawal leaves balance less
* than MIN_BALANCE. Allows for negative balance. */
 public void withdraw(double amount)
  { /* implementation not shown */ }
}

Which is correct implementation code for the withdraw method in the CheckingAccount class?

(A) super.withdraw(amount);
     if (balance < MIN_BALANCE)
       super.withdraw(FEE);
(B) withdraw(amount);
      if (balance < MIN_BALANCE)
          withdraw(FEE);
(C) super.withdraw(amount);
      if (getBalance() < MIN_BALANCE)
         super.withdraw(FEE);
(D) withdraw(amount);
      if (getBalance() < MIN_BALANCE)
         withdraw(FEE);
(E) balance -= amount;
      if (balance < MIN_BALANCE)
          balance -= FEE;

time 1000 ms
memory 32 Mb
Правила оформления программ и список ошибок при автоматической проверке задач

Статистика успешных решений по компиляторам
Комментарий учителя