Question: -JAVA Unsorted Optimized Array data structure Java ArrayList _ put comment on each line of your program PART1 Requirement - Demo_UnsortedOptimizedArray Create a project named

-JAVA

Unsorted Optimized Array data structure Java ArrayList

_ put comment on each line of your program

PART1 Requirement - Demo_UnsortedOptimizedArray Create a project named FA2018_LAB3PART1_yourLastName - add a data type class named Account_yourLastName, CheckingAccount_yourLastNameand SavingAccount_yourLastName -add data structure class named Account_UnsortedOptimizedArray (use the code in the book chapter 2 for your reference) -add driver class named Demo_UnsortedOptimizedArray_yourLastName

Provide the application that allows users can do the following tasks:

Insert One Account

Verify encapsulation of Unsorted Optimized Array

Update an account

Remove an account

Show all accounts

0. Exit

TASK1: INSERT

-Ask for information of one account. It could be checking account or saving account; insert to the data structure, then check if insert successfully display message box: Insert Account success Otherwise display message box Insert Account failed

TASK2: VERIFY ENCAPSULATION -Ask for insert a new account as task1, for example node name account -Modify the service fee (if checking account) or interest rate (if saving account) of account -Fetch the node with the same account number, store the fetched node with the name copy -compare the information just modify between account and copy If the information are the same, display message box: Unsorted Optimized Array is not encapsulated Otherwise display the messageg: Unsorted Optimized Array is encapsulated

TASK3: UPDATE -Ask for insert a new account as task1, for example node name account -Modify the service fee (if checking account) or inerest rate (if saving account) of account

-Updateaccount to the data structure -If update return true, display message box Update successfully Otherwise display message box Update failed

TASK4: REMOVE

-Ask for the account number that you want to remove -Delete that account -If delete returns true display message box: Delete successfully Otherwise display message box: Delete failed

TASK5: SHOW ALL

-show all accounts currently stored in the data structure You should allow users to continue using your program until they want to exit

PART2 Requirement Java Demo_ArrayList

Create a project named FA2018_LAB3PART2_yourLastName - add a data type class named Account_yourLastName, CheckingAccount_yourLastName and SavingAccount_yourLastName (you can re- use the classes from lab2) -add driver class named Demo_ArrayList_yourLastName

Create an ArrayList structure

Insert 52 numbers from 0 to 51 to the ArrayList

Promp to allow users to insert 3 account that can be checking account or saveing

account to the ArrayList

Insert numbers from 52 to 99 to the ArrayList

Display the size of ArrayList

Delete an object at index 52 then display the size

Fetch and print out the information of the node at index 25 (temp) and the node

at index 52 (temp1)

To verify if ArrayList is encapsulated: modify the service fee or interest rate the

node temp1 that is fetched above, then fetch the node at index 52 again (temp2). Compare the modified information of temp1 and temp2. If the information are different display message box: Java ArrayList is encapsulated

Otherwise display the message: Java ArrayList is unencapsulated

Here are the saving and checking account

- schecking

class CheckingAccount extends Account

{ public double serviceFee; public CheckingAccount() { super(); } public CheckingAccount(String acc, String nam, double bal,double fee) { super(acc,nam,bal); serviceFee = fee; } public void openAccount() { System.out.println("Account Type: Checking Account"); super.openAccount(); } public void checkBal() { System.out.println("Account Type: Checking Account"); super.checkBal(); } public void deposit(double amount) { System.out.println("Account Type: Checking Account"); super.deposit(amount); } public void withdraw(double amount) { System.out.println("Account Type: Checking Account"); super.withdraw(amount); } public void calculateFee() { super.balance-=super.balance*serviceFee*0.01; } public void printStatement() { calculateFee(); System.out.println("Account Type: Checking Account"); System.out.println("Service Fee: "+serviceFee); super.printStatement(); } }

- saving

class SavingAccountextends Account { public double interestRate; public SavingAccount() { super(); } public SavingAccount(String acc, String nam, double bal,double inter) { accNumber=acc; name=nam; balance=bal; interestRate = inter; } public void openAccount() { System.out.println("Account Type: Saving Account"); super.openAccount(); } public void checkBal() { System.out.println("Account Type: Saving Account"); super.checkBal(); } public void deposit(double amount) { System.out.println("Account Type: Saving Account"); super.deposit(amount); } public void withdraw(double amount) { System.out.println("Account Type: Saving Account"); super.withdraw(amount); } public void calculateInterest() { super.balance+=super.balance*interestRate*0.01; } public void printStatement() { calculateInterest(); System.out.println("Account Type: Saving Account"); System.out.println("Interest Rate: "+interestRate); super.printStatement(); } }

-Account

public class Account

{ public String accNumber; public String name; public double balance;

public Account() { accNumber="-1"; name="default"; balance=-1; } public Account(String acc, String nam, double bal) { accNumber=acc; name=nam; balance=bal; } public void openAccount() { System.out.println("Name is "+ name+ " account number "+ accNumber+ " balance is "+balance); } public void checkBal() { System.out.println("Account Name: "+name); System.out.println("Account Number: "+accNumber); System.out.println("Current Balance: "+balance); } public void deposit(double amount) { balance+=amount; System.out.println("Account Name: "+name); System.out.println("Account Number: "+accNumber); System.out.println("Deposit Amount: "+amount); System.out.println("New Balance: "+balance); } public void withdraw(double amount) { if(balance>amount) { balance-=amount; System.out.println("Account Name: "+name); System.out.println("Account Number: "+accNumber); System.out.println("Withdrawn Amount: "+amount); System.out.println("New Balance: "+balance); } else System.out.println("Not enough balance"); } public void printStatement() { System.out.println("Account Name: "+name); System.out.println("Account Number: "+accNumber); System.out.println("End Balance: "+balance); } }

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!