Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment: You will create a program in JAVA that manages accounts in a bank. This program will contain two classes, Account and Customer, as well

Assignment:

You will create a program in JAVA 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 customers 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 Xs.

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.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Define Administration and Management

Answered: 1 week ago

Question

Define organisational structure

Answered: 1 week ago

Question

Define line and staff authority

Answered: 1 week ago

Question

Define the process of communication

Answered: 1 week ago

Question

Explain the importance of effective communication

Answered: 1 week ago