Answered step by step
Verified Expert Solution
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 ()
- This method asks the user to enter a pin number.
- It checks to make sure the Pin number is between 4-8 digit numerical value
- It calls another method called encryptData()
- the value return from enCryptData is stored as the user security pin number.
enCryptData()
- This method takes integer value as its argument
- It encrypts the integer value using mod21 encryption security.
- 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 ()
- Asks for security pin.
- Checks if pin entered matches the user security
- If not, continue to ask user for security pin until valid pin is entered.
- Asks if withdraw from checking account or saving account
- Checks If withdraw amount is less than balance
- Withdraws the amount, and updates account balance
Deposit()
- Asks for security pin.
- Checks if pin entered matches the user security
- If not, continue to ask user for security pin until valid pin is entered.
- Asks if withdraw from checking account or saving account
- Updates account balance with new balance
Transfer()
- Asks for security pin.
- Checks if pin entered matches the user security
- If not, continue to ask user for security pin until valid pin is entered.
- Asks from and to account to transfer money (checking to saving or saving to checking_
- Updates both accounts balance
DisplayBalance()
- Asks for security pin.
- Checks if pin entered matches the user security
- If not, continue to ask user for security pin until valid pin is entered.
- Prints the account balance on both checking and Saving
Test your code with the followings
- Create an account called myAccount
- Call DisplayBalance()
- Deposit $100 in saving account
- Deposit $150 in checking account
- Display Balance
- Transfer $50 from saving account into checking account
- Display balance
- 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
- Withdraw $25 from saving account
Display Balance
NOTE: BANKAccount class in Picture
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started