Question: Java programming: Create a class called BankAccount with the following variables and methods Variables A string variable called acctHolderFirstName - This will be used to

Java programming:

Create a class called BankAccount with the following variables and methods

Variables

  1. A string variable called acctHolderFirstName - This will be used to store first Name of the account holder
  2. A string variable called acctHolderLastName This will be used to store last Name of the account holder.
  3. A double variable called acctBalance - This is used to store account current balance.
  4. A String variable called acctType - This will hold the account type. (Checking or Saving)

Methods

  1. A Default Constructor

This method will do the following

  1. Initializes acctBalance to have a value of zero
  2. Sets the acctType to Checking
  3. Calls method getAccountInfo();
  1. An overloaded Constructor that takes 4 parameters

( firstName, lastName, Balance , Type)

This method will the followings

Sets acctHolderFirstName to firstName

Sets acctHolderLastName to lastName

Sets acctBalance to balance

Sets acctType to Type

  1. A method called getAccountInfo()

This method prompts the user for First Name, Last Name, and account Type.

It initializes the class variables to values user provides.

  1. A method called Deposit()

This method asks the user to enter a double amount to deposit into acct

It adds the amount the current balance and updates the current balance amount.

  1. A method called displayBalance()

This method displays the following information

Account Holder Last Name

Account Type

Current Balance in the account

Testing Your Code

Create a class called TestAccountBalance

Instantiate a BankAccount Object called RonaldoAccount as described below

  1. Use the default constructor to create the object, and provide the following values
  2. First Name = Cristiano
  3. Last Name = Ronaldo

Using the hisAccount object call its member functions

Call DisplayBalance()

Call Deposit(), and deposit $255 into account

DisplayBlance()

Instantiate a BankAccount Object called KaylynAccount as described below

  1. Use the overloaded constructor to create the object, and provide the following values
    1. First Name = Kaylyn
    2. Last Name = Kyle
    3. Balance = 895
    4. Acct Type = Saving

Using the herAccount object to call its member functions

Call DisplayBalance()

Call Deposit(), and deposit $105 into account

DisplayBlance()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!