Create a project, and in it a class with a main.
Part A
☑ Add a class Account, which has an instance variable for a balance☑ Add a toString that returns the balance with a dollar sign
☑ Add a method deposit which takes a double and adds it to the balance.
☑ Add a method withdraw which takes a double and subtracts it from the balance. If the amount is larger than the balance, set the balance to 0. Either way, return however much money we were actually able to withdraw. So if we have balance 20, and we withdraw 5, then we return that 5 and leave balance at 15, but if we have balance 15 and withdraw 20, then we return 15 and leave balance at 0.
For both of these methods, if you are given a negative number, print a complaint and do nothing (if a method returns, it must always return something, even if it "does nothing").
Throughout this assignment, if you are depositing to or withdrawing from the account, remember to use these methods!!!
Part B
☑ Create a new class Bank, with an instance variable currentAccount, of type Account You may either give Bank an instance variable of type Scanner to use in all the methods, or just create a local scanner variable in each method that needs it. (Remember that the info on using the Scanner class is linked from the class page) ☑ In Bank create a method makeAccount, which asks the user for a starting balance. Return a new Account with that value set for its balance. ☑ In Bank, create a method starter, which sets up currentAccount, using the makeAccount method. To provide a menu, you will create methods, mainMenu, depositMenu, and withdrawMenu. ☑ In mainMenu, In a loop, print a list of options for the user 1. Show Balance☑ In Account, add an instance variable jointAccount, which is an Account.
☑ Add a method join which takes an account, and makes each Account the other's jointAccount.
Go back and change the toString so that if there is a joint account, we now get something like
$4583.02 ($2273 available in joint account)
☑ Add a method transferFromJoint which takes a double amount, and if there is a joint account, withdraws amount from jointAccount and deposits it to this account If there is no jointAccount, print a complaint.
☑ Add a similar method transferToJoint which takes a double amount, and if there is a joint account, moves amount in the other direction, with the same rules.
☑ In Bank, add to the main menu another option: Create Joint Account☑ To the deposit menu, add the option
3. Transfer From Joint Account and if they enter 3, transfer from the joint account to the account an amount specified by the user. ☑ To the withdrawal menu, add the option 3. Transfer To Joint Account and if they enter 3, ask them how much to transfer, and then transfer it[EC]
Add to Account a double instance variable penalty. Each time they try to withdraw more money than they have, add $2 to their penalty. Whenever they deposit an amount, deduct as much of the the penalty as possible from that amount before depositing, and reduce the penalty accordingly.
So, if a user made three withdrawals that incurred the penalty, their penalty would be $6. If they then deposit $5, they will end up depositing $0, but the penalty will be down to $1, if then they deposit another $5, they will actually deposit $4 and the penalty will be down to $0.
In the toString, if there is currently a penalty, include it.