RUVIDEO
Поделитесь видео 🙏

Java Practice It | Exercise 8.11 transactionFeeBankAccount | classes, instance methods смотреть онлайн

More practice its:
https://youtube.com/playlist?list=PLZPy7sbFuWVgDWN1GImGRm_2Lh6IydaEH



Problem:
https://practiceit.cs.washington.edu/problem/view/bjp5/chapter8/e11-transactionFeeBankAccount



Question:
Suppose that you are provided with a pre-written class BankAccount as shown below. (The headings are shown, but not the method bodies, to save space.) Assume that the fields, constructor, and methods shown are already implemented. You may refer to them or use them in solving this problem if necessary.

Write an instance method named transactionFee that will be placed inside the BankAccount class to become a part of each BankAccount object's behavior. The transactionFee method accepts a fee amount (a real number) as a parameter, and applies that fee to the user's past transactions. The fee is applied once for the first transaction, twice for the second transaction, three times for the third, and so on. These fees are subtracted out from the user's overall balance. If the user's balance is large enough to afford all of the fees with greater than $0.00 remaining, the method returns true. If the balance cannot afford all of the fees or has no money left, the balance is left as 0.0 and the method returns false.

// A BankAccount keeps track of a user's money balance and ID,
// and counts how many transactions (deposits/withdrawals) are made.
public class BankAccount {
private String id;
private double balance;
private int transactions;

// Constructs a BankAccount object with the given id, and
// 0 balance and transactions.
public BankAccount(String id)

// returns the field values
public double getBalance()
public String getID()
public String getTransactions()

// Adds the amount to the balance if it is between 0-500.
// Also counts as 1 transaction.
public void deposit(double amount)

// Subtracts the amount from the balance if the user has enough money.
// Also counts as 1 transaction.
public void withdraw(double amount)

// your method would go here
}
For example, given the following BankAccount object:

BankAccount savings = new BankAccount("Jimmy");
savings.deposit(10.00);
savings.deposit(50.00);
savings.deposit(10.00);
savings.deposit(70.00);
The account at that point has a balance of $140.00. If the following call were made:

savings.transactionFee(5.00);
Then the account would be deducted $5 + $10 + $15 + $20 for the four transactions, leaving a final balance of $90.00. The method would return true. If a second call were made,

savings.transactionFee(10.00);
Then the account would be deducted $10 + $20 + $30 + $40 for the four transactions, leaving a final balance of $0.00. The method would return false.

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Java Practice It | Exercise 8.11 transactionFeeBankAccount | classes, instance methods» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.