Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the Bank Account class you created to have the following additional functionality When the object is created, it should create two types of account

Modify the Bank Account class you created to have the following additional functionality

  • When the object is created, it should create two types of account
    • Checking and Saving ( you can user Boolean variables to identify between these accounts)
    • Initialize balance on both accounts to $0
    • The constructor calls a method called setAccountPassWord()

setAccountPassWord ()

  1. This method asks the user to enter a pin number.
  2. It checks to make sure the Pin number is between 4-8 digit numerical value
  3. It calls another method called encryptData()
  4. the value return from enCryptData is stored as the user security pin number.

enCryptData()

  1. This method takes integer value as its argument
  2. It encrypts the integer value using mod21 encryption security.
  3. Returns the encrypted value to calling function.

Example

12345 %21 - this returns 18 which is the remainder

656564 % 21 this returns 20 which is the remainder

Add the following additional methods

Withdraw ()

  1. Asks for security pin.
  2. Checks if pin entered matches the user security
    1. If not, continue to ask user for security pin until valid pin is entered.
  3. Asks if withdraw from checking account or saving account
  4. Checks If withdraw amount is less than balance
  5. Withdraws the amount, and updates account balance

Deposit()

  1. Asks for security pin.
  2. Checks if pin entered matches the user security
    1. If not, continue to ask user for security pin until valid pin is entered.
  3. Asks if withdraw from checking account or saving account
  4. Updates account balance with new balance

Transfer()

  1. Asks for security pin.
  2. Checks if pin entered matches the user security
    1. If not, continue to ask user for security pin until valid pin is entered.
  3. Asks from and to account to transfer money (checking to saving or saving to checking_
  4. Updates both accounts balance

DisplayBalance()

  1. Asks for security pin.
  2. Checks if pin entered matches the user security
    1. If not, continue to ask user for security pin until valid pin is entered.
  3. Prints the account balance on both checking and Saving

Test your code with the followings

  1. Create an account called myAccount
    1. Call DisplayBalance()
  2. Deposit $100 in saving account
  3. Deposit $150 in checking account
    1. Display Balance
  4. Transfer $50 from saving account into checking account
    1. Display balance
  5. Try to withdraw $200 from your saving account and see what happens. You must properly display code and inform the end user if there is not funding in the account
  6. Withdraw $25 from saving account

    Display Balance

    NOTE: BANKAccount class in Picture

image text in transcribed

9 public class BankAccount { 10 // declaring the final values String accHolderFirstName; // value for the first name of account holder String acctHolderLastName; //value for the first name of account holder 13 double acctBalance; // variable for account balance, String acctType;//variable for account type 15 Scanner sc = new Scanner(System.in); // importing a scanner object 160 BankAccount(71 creating a method for bank account 17 18 19 this.acctBalance = 255;// calling the account balance variable this.acctType = "Checking":// calling and assigning account type getAccountInfo(); 20 BankAccount(String firstName, String lastName, double balance , String Type) 27 this.acctHolderFirstName = firstName; this.acctHolderLastName = lastName; this.acctBalance = balance; this.acctType = Type; 28 29 300 31 32 33 34 35 void getAccountInfo() { // printing out the bank account holder information System.out.println("First Name"); acctHolderFirstName = sc.nextLine(); // allows user to type in first name System.out.println("Last Name"); acctHolderLastName = sc.nextLine();// allows user to enter last name System.out.println("Account Type"); acctType = sc.nextLine(); // allows user to type in account type 36 37 38 39 400 41 void deposit() 43 44 45 double deposit = sc.nextDouble this.acctBalance = this.acctBalance + deposit; 46 470 void displayBalance() 48 49 50 51 53 } System.out.println(this.acctHolderLastName); // prints out the user last name System.out.println(this.acctType);//prints out account type System.out.println(this.acctBalance); // prints out first name, 52 9 public class BankAccount { 10 // declaring the final values String accHolderFirstName; // value for the first name of account holder String acctHolderLastName; //value for the first name of account holder 13 double acctBalance; // variable for account balance, String acctType;//variable for account type 15 Scanner sc = new Scanner(System.in); // importing a scanner object 160 BankAccount(71 creating a method for bank account 17 18 19 this.acctBalance = 255;// calling the account balance variable this.acctType = "Checking":// calling and assigning account type getAccountInfo(); 20 BankAccount(String firstName, String lastName, double balance , String Type) 27 this.acctHolderFirstName = firstName; this.acctHolderLastName = lastName; this.acctBalance = balance; this.acctType = Type; 28 29 300 31 32 33 34 35 void getAccountInfo() { // printing out the bank account holder information System.out.println("First Name"); acctHolderFirstName = sc.nextLine(); // allows user to type in first name System.out.println("Last Name"); acctHolderLastName = sc.nextLine();// allows user to enter last name System.out.println("Account Type"); acctType = sc.nextLine(); // allows user to type in account type 36 37 38 39 400 41 void deposit() 43 44 45 double deposit = sc.nextDouble this.acctBalance = this.acctBalance + deposit; 46 470 void displayBalance() 48 49 50 51 53 } System.out.println(this.acctHolderLastName); // prints out the user last name System.out.println(this.acctType);//prints out account type System.out.println(this.acctBalance); // prints out first name, 52

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

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

a. Do team members trust each other?

Answered: 1 week ago

Question

How do members envision the ideal team?

Answered: 1 week ago

Question

Has the team been empowered to prioritize the issues?

Answered: 1 week ago