2.Instruction Then it will display the number of


Instruction to runprogram2.1 Open projectOpen project Bank System then click on run proyect or press F6on your keyboard. 2.2 Program choiceAs it is a console run program awindow will appear and prompt the user to enter a choice number:      1- CREATE A BANK ACCOUNT       2- PRINT ALL ACCOUNTS       3- DELETE ACCOUNT       4- DEPOSIT SOME MONEY       5- WITHDRAW SOME MONEY       6- PRINT TRANSACTIONS       0- EXIT 2.

Best services for writing your paper according to Trustpilot

Premium Partner
From $18.00 per page
4,8 / 5
Writers Experience
Recommended Service
From $13.90 per page
4,6 / 5
Writers Experience
From $20.00 per page
4,5 / 5
Writers Experience
* All Partners were chosen among 50+ writing services by our Customer Satisfaction Team

3 Create bank accountTo create a new bank account pressnumber 1If choose 1 the program will prompt the user to enter a new accountnumber, name, address and opening balance. Then it will display a message Thisaccount with account no: … is now opened and active…Your account balance is now … 2.4 Print all accountsTo print all accounts, press number2. It will display every account details that is stored (name, account number,address, status, current balance and opening date). 2.

5 Delete accountTo delete an account press number3. It will prompt the user to enter account number the user wants to delete. Itwill display Deletion successful.

  2.6 Deposit moneyTo make a deposit press number 4.It will prompt the user to enter account number the user wants to deposit moneyand the amount. Once finish it will display a message “Transaction addedsuccessful”. 2.7 Withdraw moneyTo withdraw money press number 5 Itwill prompt the user to enter account number the user wants to withdraw moneyand the amount.

Once finish it will display a message “Transaction addedsuccessful”. 2.8 Print transactionsTo print last six transactionspress number 6. It will prompt the user to enter from which account number theuser wants to display the transactions. Then it will display the number oftransactions, type, mount, before and after the transaction, date. 2.9 ExitTo exit the program, press 0.

Itwill display a message “Good Bye”.             3. Description3.

1 Bank ClassThe Bank class is the interface of the program, it uses the TreeMap data structure to store newaccounts in ascending order created by the user input. TreeMap is a map implementation that keeps its entries sortedaccording to the natural ordering of its keys or better still using a comparator if provided by the user atconstruction time. • private TreeMap accounts = new TreeMap() is a variable for creating new accounts.•public void setAccounts(TreeMap accounts) and public Account • getAccount(IntegeraccountNumber) They serve to set and get values from class variables thatare defined as ‘private’, but these method are defined as ‘public’ becausesecurity issues. • public TreeMap < Integer, Account > openNewAccount(TreeMap accounts, Account account) and public TreeMap < Integer, Account > removeAccount(TreeMap< Integer, Account > accounts, Account account) will create and removenew accounts and will be stored in the variableaccount.  accounts.

put(account.getAccountNo(), account).•Treemap has a Set keyset() method that I used to store the account number from the user input.The set cannot store duplicate values. The keyset will return a set view of thekeys contained in this map.

• The Bank class uses Scanner class which is a text scanner that can parse primitivetypes and strings using regular expressions in other words it will allow theuser to read values of various types. •  Scanner class is used to read input from the keyboard. “system.in” is InputStream is connected to keyboardinput of console program, in this case Java.• Scanner scan = new Scanner(System.in); itis the constructor of Scanner withargument System.

in and will return areference to newly constructed object.• Iused different methods of the Scanner class like nextInt() scans the next token of the input as a int.  , nextDouble()scans the next token of the input as a double. and nextLine()returns the rest of the current line, excluding any line separatorat the end.• Ihave created a set of instructions that will prompt the user to press a numberfor each action they wish to proceed (from 0 to 6)Iam using the Switch statement whichis mostly used with break statement it allows a variable to be tested forequality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.Case 0: is System.

exit(0) wich was setup against a while loop, while the input wasn’t 0 it would do other statementbut if the input is 0 it will terminate the program with a “Good Bye” display.Case 1: there is Boolean flag = falseto start the case. If false you canproceed in create a new account number accountNo = scan.

nextInt() which issaved in the variable accountNo and Set keySet =bank.accounts.keySet() which is a Treemapmethod, keyset will be stored in thevariable key. Once entered theaccount holder name, address, balance the new account will be saved in the variable account. If flag true accountNo.

equals(key) which means there is already a account numberwith the same number. After the new account is created a message display willappear “This account with account number:… is now opened and active, yourbalance is…”Case 2: is keySet =bank.accounts.keySet() which will display all existing accounts, the for loopwill search for every keyset that is stored in the variable key that is saved in the accounts Treemap.

It will also display theposition of the keyset.Case 3: it starts with Boolean flag =false to start the case. If false Ineed to enter the account number I wish to delete from the system.

Thefor loop will search for the key, for(Integerkey: keySet) and if it matches a keystored in the accounts variable (Treemap) then bank.removeAccounts(bank.removeAccount(bank.getAccounts(),account))  it will remove the key.Ifflag = true which means id did not find the key it will display a message  “Account number is not present”.Case 4:  Iffalse I need to enter the account number you wish to deposit money, the forloop will search for every keyset that is stored in the variable key that is saved in the accounts Treemap. Once it founds the key if(accountNo.

equals(key)) you need toenter amount you wish to deposit and is stored in account.deposit(account, depositAmount). If Flag = true  it means the key doesn’t match so it will goand a display message “Account number is not present”.Case 5: If false I need to enter the account number you wish to withdrawmoney, the for loop will search for every keyset that is stored in the variablekey that is saved in the accounts Treemap. Once it founds the key if(accountNo.equals(key)) you need toenter amount you wish to withdraw and is stored in account.withdraw(account, withdrawtAmount). If Flag = true  it means the key doesn’t match so it will goand a display message “Account number is not present”.

Case 6: will display last 6 transactions if (bank.accounts.containsKey(accountNo)) matches the key the userjust entered then it will display transaction details of that key (account.transactions).Else will print “Input Error, entercorrect account number”.  3.2 Account ClassThe Account class is where transactions are stored in the program, ituses the LinkedList whichis a linear data structure where each element is a separate object.

LinkedList is implementationof the List.• Queuetransactions = new LinkedList() is where new tranactions arestored in the LinkedList• Queue is a data structure interfaceand is a subtype of the Collection interface. It represents an ordered list ofobjects just like a List, but its intended use is slightly different.

A queueis designed to have elements inserted at the end of the queue, and elementsremoved from the beginning of the queue (FIFO).• The java.util.Date will allow meto record the time the account was created.

• Is in this class where theoperations of the transactions are made like account balance, deposit withdrawand where the program keeps the last 6 transactions.• I started by importingjava.util.collections, Date, LinkedList, List and Queue and by creatingvariables for account holder’s name(String), address(String), number(int),status(String), balance(double) and date() then constructor and set and getmethods for the account Holder. Also get and set for Queue.• @Override annotation is used whenwe override a method.• The toString() method returns the string representation of theobject to represent any object as string.• public voidaddTransaction(Transaction transaction) will add a new transacation totransactions variable.

If transactions sizeis greater than five, the Queue method pollretrieves and removes the head of the queue or returns null if queue isempty. If not, the Queue method offer inserts an element to the queue.• The deposit method will allow the user to deposit money it willcreate variable transaction for new transaction then it will set thetransactions Id, type, amount and balance. If deposit is less than 0 it will display a message “amount should be greater than0”. If not it will set the current balance which would be accountBalance +depositAmount .• transaction.

setMoneyAfterTransaction(getAccountBalance())will retrieve the new account balance.• addTransaction(transaction) willadd the new transaction.• Collections.

sort((List)transactions) will sort the transactions by the amount.• The withdraw method is pretty much the same as the deposit method wthe only difference isin accountBalance – withdrawAmount it will substract against the accountbalance.  3.3 Transaction Accountpublic class Transaction implementsComparableThe Transaction account is wherethe program sorts the Transaction by implementing comparable interface.

As youcan see I have implemented the Comparable interface in my Transaction classbecause I want to sort the objects of this class.• I have imported java.util.Date asis required by specification to add a transaction date and by creating variablesfor transaction’s description(String),amount(double), Id(int), money beforetransaction(double), money aftertransaction(double) and date()then constructor and set and get methods for the Transactions.

• this.transactionId =transactionId +1 will start with number 1 to display list when called otherwise will start with 0.• The toString() method returns the string representation of theobject to represent any object as string.

• public int compareTo(TransactionotherTransaction)• Transaction other = (Transaction)otherTransaction it will create a variable other and compare to transaction.• return (int)(other.amount-this.amount) will return the amount in descending order.

  3.4 Purpose The purpose of the bank class wasto be the interface o the program and where the accounts where stored. The purpose of the account classwas to create the account details and is there where the transactions arestored, and transactions operations are performed.The purpose of the transactionclass is to create the transaction details and is there where the sorting ofthe transaction by amount is done.

I have used different datastructure because I believe it give me a better outcome like I chose queue becauseit would use the method FIFO and LinkedList will allow me to stored thetransactions.Also I chose to use Treemap  because is a data structure to store newaccounts in ascending order created by the user input.               4. Testing (screenshots)4.1 Create new account •Screen shot of program choices.

User have chosen to create a new accountby pressing 1.    • Newaccount created.     4.2 Print all accounts •Screen shot of all accounts.

User havechosen to print all accounts bypressing 2.        4.3 Delete account•Screen shot of deleted account.User have chosen to delete accountby pressing 3.•In this case the user chose to delete account number 2.

   4.4 Deposit money•Screen shot of deposit money. Userhave chosen to deposit money into accountby pressing 4.

•In this case the user chose to deposit money into account number1 with amount 500.        4.5 Withdraw money•Screen shot of withdraw money.User have chosen to withdraw money into accountby pressing 5.•In this case the user chose to withdraw money into account number1 with amount 50.

 4.6 Print transactions(Descending order)•Screen shot of print transactions.User have chosen to print transactions bypressing 6.•In this case there are 2transactions one deposit and one withdraw sorted by transaction amount.  4.7 Exit•Screen shot of exit program. User havechosen to exit program by pressing 0.    4.

8 Sorting (2ndpart)•Screen shot of exit programrunning the sorting algorithm (Bubble sort)         5. Implementation of data structureand                     algorithm (2ndpart) I created two classes for this 2ndpart of the coursework and I called them MyQueue and My Queue Test.  I chose to use LinkedList as a datastructure and I started from scratch as it was required.

• queue = new LinkedList(): I named myvariable queue.• public int size(): to retrievenumber of elements on queue.• public Integer first(): to get firstelement on queue.

 • public Integer dequeue(): to remove firstelement on queue.• public void enqueue(Integer N): toadd element on queue. • for (Integer queue1 : queue) this loop willprint every  value in queue. I also chose to use the Bubble Sort algorithm as is a simplealgorithm that works by constantly swapping the adjacent elements if they arenot in the correct order.I used two specifics sources to dothis part of the coursework one exercise from the workshop and the other onefrom the website which I will add them below.

 GeeksforGeeks.(2018). Bubble Sort – GeeksforGeeks. online Available at:https://www.

geeksforgeeks.org/bubble-sort/ Accessed 5 Jan. 2018.

 Exercise 22.26 Solution: ListTest.java-Programallows insertion and deletion anywhere in a linked list.  6.

ReflectionI believe this is the most challengingtask I have been given in term of coursework for the complexity of the programitself I have struggled a lot to make the classes work combinedly. I chose touse the scanner class but I’m questioning myself if I made the correct decisionby not using GUI as per previous experience I felt I was more confident byusing it.  One of the problems I had whenusing Queue was Collections.sort(transactions)in account class it throws an error argument mismatch (queue cannot convert to list) to correct this error I had to Cast transactions to List. Furthermore,I have encountered lots of problems trying to write a code that will reflectwhat I was asked from the information provided in the coursework I believe Icould have probably wrote the code differently maybe more efficiently, but thisis a learning curve to me and I know a lot more now than I did before I startedthis coursework. All classes are my work, but I have used loads of sourcesmainly from the net where I saw some samples.

I will add them bellow but becausethey are a lot I will be adding some. ReferenceJava, C.,I/O, J.

, Tutorial, C. and Singh, C. (2018). TreeMap in Java with Example.

online beginnersbook.com. Available at:https://beginnersbook.com/2013/12/treemap-in-java-with-example/ Accessed 4Jan. 2018.www.javatpoint.

com.(2018). Java Comparable – javatpoint. online Available at:https://www.

javatpoint.com/Comparable-interface-in-collection-frameworkAccessed 4 Jan. 2018.www.

javatpoint.com.(2018). Java Map – javatpoint.

online Available at:https://www.javatpoint.com/java-map Accessed 4 Jan. 2018.Java, C.,I/O, J., Tutorial, C. and Singh, C.

(2018). Comparable Interface in Javawith example. online beginnersbook.com. Available at: https://beginnersbook.com/2017/08/comparable-interface-in-java-with-example/Accessed 4 Jan.

2018.GeeksforGeeks.(2018). Queue | Set 2 (Linked List Implementation) – GeeksforGeeks.online Available at:https://www.

geeksforgeeks.org/queue-set-2-linked-list-implementation/ Accessed4 Jan. 2018.www.tutorialspoint.com.(2018). Java The TreeMap Class.

online Available at:https://www.tutorialspoint.com/java/java_treemap_class.htm Accessed 4 Jan.2018.www.tutorialspoint.com.

(2018). java.util.TreeMap.keySet() Method Example.

online Availableat: https://www.tutorialspoint.com/java/util/treemap_keyset.htm Accessed 4Jan. 2018.

Codejava.net.(2018). Java Map Collection Tutorial and Examples. online Availableat: http://www.codejava.net/java-core/collections/java-map-collection-tutorial-and-examplesAccessed 4 Jan.


(2018). Java Queue Collection Tutorial and Examples. online Availableat:http://www.codejava.

net/java-core/collections/java-queue-collection-tutorial-and-examplesAccessed 4 Jan. 2018.scratch, C.

(2018). Creating a LinkedList class from scratch. onlineStackoverflow.com.

Available at:https://stackoverflow.com/questions/4066729/creating-a-linkedlist-class-from-scratchAccessed 4 Jan. 2018.Tutorials.jenkov.com.(2018). Cite a Website – Cite This For Me.

online Available at:http://tutorials.jenkov.com/java-collections/queue.html Accessed 4 Jan. 2018.java?, H.

(2018). How do I instantiate a Queue object in java?. onlineStackoverflow.com. Available at: https://stackoverflow.com/questions/4626812/how-do-i-instantiate-a-queue-object-in-javaAccessed 4 Jan.