Assignment:

You will create a program that manages accounts in a bank. This program will contain two classes, Account and Customer, as well as the driver class. You will create a customer record within the driver and then create new accounts for the customer, deposit, withdraw, transfer funds, and consolidate accounts. Display messages within each method that tells the user what transaction has occurred. See sample run.

Validation: Be sure to validate the customer's social security number. In addition, if a user enters a string instead of a character, such as 'open instead of o, your program should be able to accept it without an error, as well as handle different upper and lower case. It also needs to handle any invalid entries that might be entered with any of the user inputs.

Customer class:

Instance variables:

  • Number of accounts- This is an integer variable that keeps track of how many accounts each customer holds.
  • Name: String
  • Social security number: This is a String variable that stores the users id number. It must be in the format of XXX-XX-XXXX.

Methods:

  • Constructors: Create a constructor that receives name and ssn and sets number of account to zero.
  • Getters and setters
  • toString should display customer name and ssn with labels. SSN should be displayed in XXX-XX-last four format where only the last four digits are shown and the remaining digits are presented with X's.
  • equals- Two customers are equal if their ssn numbers match

Account class:

Instance variables:

  • Number of accounts- This is an integer static variable that keeps track of the number of accounts that the bank has.
  • balance- This is a double variable that stores the account balance. social security number- This is a String variable that stores the ssn from the customer.
  • account number- This is a String variable that will be created using a random number generator and then converted to a String.

Methods:

  • Constructors: Create a constructor that accepts balance and Customer. To set the account number, you will generate a random number. Then use the Integer.toString() method to convert the integer value into a String and then store that in the instance variable. The ssn will be created by retrieving the customer ssn.

    You will then need to increase the number of accounts by 1 and increase the customer number of accounts by 1.
  • Getters and setters
  • toString that outputs the account number and balance
  • equals- Two accounts are equal if the account numbers match
  • deposit- This method will increase the balance by the amount received through the parameter, only if the amount is positive.
  • withdraw- This method receives amount to be withdrawn and withdraws that amount if the amount is positive and only if after the withdraw, the balance remains positive.
  • consolidateAccounts- This method receives two accounts and a customer. It combines the balances from the two accounts and creates a third account. It will then close the first two accounts.
  • transferAccounts- This should be a static method that receives two accounts and an amount to transfer. Be sure to add funds to one account and deduct funds from the other.
  • outputMenu- This method should output the menu of options for the user. See the sample output for details.
  • Any other methods you deem necessary

BankDriver Class:

  • Using the sample run as your template, create the driver class.
  • Start by creating a customer and then display the menu repeatedly until the customer chooses to quit, completing tasks for each menu item.
  • Use a switch statement to process the menu choices.
  • When the customer quits, the program should output the total number of accounts that customer has as well as how many accounts the bank has.
  • You must have at least three methods in addition to the main method within the driver class.

Sample Program Run

Below is a sample run of Program 4. Items in green are user input

Enter the customer name:
Suzie Woozie
Enter the customer social security number:
12-345-6789
Not in the correct format. Try again.
Enter the customer social security number:
123456789
Not enough characters. Please re-enter!
Enter the customer social security number:
123-45-6789
Creating a new customer
Customer :Suzie Woozie

Social Security Number: xxx-xx-6789
Total Accounts: 0


Choose an option:
O: Create or open an account
D: Deposit to account
W: Withdraw from account
T: Transfer funds
C: Consolidate accounts
X: Close account
Q: Quit
o

How much do you want to deposit into your new account?
1000

Creating an account

Account Number: 89300
Balance: $1000.0
Customer :Suzie Woozie

Social Security Number: xxx-xx-6789
Total Accounts: 1


Choose an option:
O: Create or open an account
D: Deposit to account
W: Withdraw from account
T: Transfer funds
C: Consolidate accounts
X: Close account
Q: Quit
o

How much do you want to deposit into your new account?
500

Creating an account

Account Number: 21512
Balance: $500.0
Customer :Suzie Woozie

Social Security Number: xxx-xx-6789
Total Accounts: 2


Choose an option:
O: Create or open an account
D: Deposit to account
W: Withdraw from account
T: Transfer funds
C: Consolidate accounts
X: Close account
Q: Quit
d

How much do you want to deposit into account 1?
100

Account Number: 89300
Balance: $1000.0

Depositing funds

Account Number: 89300
Balance: $1100.0

How much do you want to deposit into account 2?
0
No funds deposited

Account Number: 21512
Balance: $500.0


Choose an option:
O: Create or open an account
D: Deposit to account
W: Withdraw from account
T: Transfer funds
C: Consolidate accounts
X: Close account
Q: Quit
w

How much do you want to withdraw from account 1?
1200
Insufficient funds!

Account Number: 89300
Balance: $1100.0

How much do you want to withdraw from account 2?
300

Withdrawing funds!

Account Number: 21512
Balance: $200.0


Choose an option:
O: Create or open an account
D: Deposit to account
W: Withdraw from account
T: Transfer funds
C: Consolidate accounts
X: Close account
Q: Quit
t

How much money do you want to transfer?
1500

You have two accounts: 1-89300 and 2-21512
Which account are funds being withdrawn from?
1
Insufficient funds to make that transfer!

Account Number: 89300
Balance: $1100.0

Account Number: 21512
Balance: $200.0


Choose an option:
O: Create or open an account
D: Deposit to account
W: Withdraw from account
T: Transfer funds
C: Consolidate accounts
X: Close account
Q: Quit
t

How much money do you want to transfer?
500

You have two accounts: 1-89300 and 2-21512
Which account are funds being withdrawn from?
1
Transferring funds!

Account Number: 89300
Balance: $600.0

Account Number: 21512
Balance: $700.0


Choose an option:
O: Create or open an account
D: Deposit to account
W: Withdraw from account
T: Transfer funds
C: Consolidate accounts
X: Close account
Q: Quit
c

Creating an account

Consolidating accounts!

Account Number: 81201
Balance: $1300.0

Closing account

Closing account


Choose an option:
O: Create or open an account
D: Deposit to account
W: Withdraw from account
T: Transfer funds
C: Consolidate accounts
X: Close account
Q: Quit
x

Closing account


Choose an option:
O: Create or open an account
D: Deposit to account
W: Withdraw from account
T: Transfer funds
C: Consolidate accounts
X: Close account
Q: Quit
q
Customer has 0 accounts
Bank has 0 accounts.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.