Computers and Technology

/* Work to do: 1) add toString method to BankAccount and SavingsAccount classes
2) Override the withdraw() in SavingsAccount so that it will not withdraw more money than is
currently in the account.
3) Provide constructors for SavingsAccount
4) Add this feature to SavingsAccount: If you withdraw more than 3 times you are charged $10 fee
and the fee is immediately withdrawn from your account. once a fee is deducted you get another 3 free withdrawals.
5) Implement the Comparable Interface for SavingsAccount based on balance.
Once you finish adding/modifying the code make sure it compiles and run.
Submit your modified InheritanceTester. java file to the assignment folder
Warning: Notice that there are 3 classes in one file, and only one of them is public,
and this public class name should be the filename. Be careful about the { } braces.
*/
public class InheritanceTester{
public static void main(String[] args){
SavingsAccount tom = new SavingsAccount(5000);
SavingsAccount kim = new SavingsAccount();
tom. withdraw(100);tom. withdraw(1000);tom. withdraw(200);
kim. withdraw(100);//should print error message: Insufficient balance
System. out. println(tom);//should print $3700 as balance
tom. withdraw(1000);
System. out. println(tom);//should print $2690 as balance, and fee charged
tom. withdraw(1000);
System. out. println(tom);//should print $1690 as balance
}
}
class BankAccount
{
private double balance;
public BankAccount()
{ balance = 0; }
public BankAccount(double initialBalance)
{ balance = initialBalance; }
public void deposit(double amount)
{ balance = balance + amount; }
public void withdraw(double amount)
{ balance = balance - amount; }
public double getBalance()
{ return balance; }
}
class SavingsAccount extends BankAccount{
//add code here.
}

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 01:10, kristofwr3444
Are special combinations of keys that tell a computer to perform a command. keypads multi-keys combinations shortcuts
Answers: 1
image
Computers and Technology, 23.06.2019 12:00, deflox74
What does the level 1 topic in a word outline become in powerpoint? a. first-level bullet item b. slide title c. third-level bullet item d. second-level bullet item
Answers: 1
image
Computers and Technology, 24.06.2019 06:00, bzhsh8282
Hey i really need some solving this problem: 1. encrypt this binary string into cipher text: 110000. include in your answer the formula the decoder would use to decrypt your cipher text in the format (coded answer) x n mod (m) = y & 2. decrypt this cipher text into a binary string: 106 you.
Answers: 2
image
Computers and Technology, 24.06.2019 17:30, KaleahV
List at least one thing to check for when you're checking the clarity and professionalism of a document.
Answers: 1
Do you know the correct answer?
/* Work to do: 1) add toString method to BankAccount and SavingsAccount classes
2) Override t...

Questions in other subjects: