Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PART1 Requirement Create the an application that can use different types of Linked List to manage either Checking Account or Saving Account. The application should

PART1 Requirement

Create the an application that can use different types of Linked List to manage either Checking Account or Saving Account. The application should allow users can select the type of Linked List to work on. After finishing one, users can select to work with other type of Linked List until they want to exit

Singly Linked List

Singly Linked List with Iterator

Java Linked List with Iterator

You can re-use the class Account_yourLastName, CheckingAccount_yourLastName and SavingAccount_yourLastName

FOR SINGLY LINKED LIST DO THE FOLLOWING TASKS: Create a Singly Linked List then allow users to do the following tasks:

Insert account

Read account

Verify Encapsulation

Close account

Delete account

Show all accounts

0. Exit

After finishing one task, the program should re-display the menu to allow users to continue to do other tasks until they want to exit

Insert Account

-display message to ask users to enter all the information that needs to create either a Checking account or Saving account -Insert that account to the Singly Linked List. -Check if Insert returns true, display message The account is open

-If insert returns false, display message: Cannot open this account

Read Account

Allow users to enter the account number to look for the Checking Account or Saving Account. - If the Singly Linked List is empty, display the message: There is no node in the Singly Linked List

- If the account cannot be found, display the message: Account cannot be found - If the it is found, display the information of the chekcing account or saving account found

VERIFY UNCAPSULATION

-ask for information of either a Checking account or Saving account named temp1 -insert account temp1 to the Singly Linked List -Change the address or one filed of account temp1 -fetch one account from Singly Linked List with the same account number of temp1 to the variable temp2

-compare the address of temp1 and temp2 (or the field you have change on temp1)

* if both address are the same: display the message: Singly Lnked List is not encapsulated * If their addresses are different, display the message: Singly Linked Lst is encapsulateded

UPDATE

-ask for information of either a Checking account or Saving account named temp -insert account temp to the Singly Linked List -Change the address or one filed of account temp -Update temp to the Singly Linked List

-Check if update returns true, display message Update successfully -if update returns false, display message Update Not successfully

DELETE

- allow users to enter the account number of the account that they want to delete Delete the account with the id. -Check if delete returns true, display message Account is closed -If delete returns false, display message Delete account failed

SHOW ALL

-show all accounts in the Singly Linked list

FOR SINGLY LINKED LIST WITH ITERATOR

Create a Singly Linked List with Iterator then do the following steps:

INSERT

-Allow users to insert 5 accounts (either Checking Account or Saving Account) to the Singly Linked List with Iterator SHOW ALL -show all 5 accounts in the Singly Linked List with Iterator

DELETE

-move iterator to delete the third account in the Singly Linked List with Iterator -show all accounts to verify the account is deleted

FOR THE JAVA LinkedList

Create a java LinkedList then do the following steps:

INSERT

-Allow users to insert 5 accounts (either Checking Account or Saving Account) to the Singly Linked List with Iterator FETCH -Fetch two first accounts in the Java LinkedList

UPDATE

-fetch the node at the current location of iterator to variable temp -change the address or a field of account temp -update the account at the current location with new temp -check if update returns true, display message Account is updated -if update returns false, display message: Update failed

SHOW ALL

-show all the LinkedList to see all accounts

*Step1: Create the pseudo-code [QA2] *Step2: Write the code

-start editor create the project, add .java file [QA1b] or [QA1d]

-follow the pseudo-code and use java to write the code of the program *Step3: compile and run the program *Step4: debug if there is any errors to complete the program

HINTS:

Create the project FA2018LAB5_yourLastName

Add 3 data type classes: Account_yourLastName, CheckingAccount_yourLastName, SavingAccount_yourLastName

Add data structure classes: SinglyLinkedList (using the code from the book for your reference)

Add data structure class SinglyLinkedListIterator (using the code from the book for your reference)

Add driver class named: Demo_LinkedList_yourLastName

HERE ARE ACCOUNT, CHECKING ACCOUNT and SAVING ACCOUNT DATA

For 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);

}

}

For Checking Account

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();

}

}

For Saving Account

class SavingAccount extends 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();

}

}

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

More Books

Students also viewed these Databases questions

Question

5. Describe how contexts affect listening

Answered: 1 week ago