Transcribed TextTranscribed Text

Project Part 2 Notes: You may un-compress your zip file to double check that you include and submit the right contents. Write your name as a comment line at the very beginning of each java program. (losing 1 point for each file without your name on top of each source file.) The compressed file name must be YourLastName_ FirstName_ (1 point) The subject of your submission email is the same as your file name, such as YourLastName_FirstName_P2. (1 point) I provide a text file, accounts.txt. You should download this text file into the directory of your Netbeans project. Each row in the file is an account record and is in the format of iccountNumber<>openDate<>customerName<>balance, where <> is the partition between two fields and the openDate is in the format of year/month/day Make sure when reading or writing this text file programmatically, your program uses the file name without an explicit path (so called relative path). For instance, File accountFile - new File ("accounts txt" For more information about the absolute path, refer to chapter 18 lecture slides. Failing to use the relative path loses 2 points. You do not need to write anything in the body of the submission email. Do not ask questions using Blackboard email which is for submitting your work only. Project submitted within two hours after the deadline may be accepted under the penalty of 10% of point deduction per hour late. Any submission more than two hours late is not accepted or graded. In the part 2, you re-use the Account and CheckingAccount classes from the prior part 1. So in addition to these two classes from the part 1 and the provided accounts.txt file, your part 2 project includes the following AccountUtility and TestPart2 classes. AccountUtility listNumbers: ArrayList mapNumAccounts: LinkedHashMap AccountUtility() readFile(): void getlistNumbers(): ArrayList getMapNumAccounts(): Linked HashMap saveFile(Linked HashMap):void 1 1. AccountUtility class This class has methods to read a provided file, accounts.txt, update the file, and provide data from the accounts.txt for other program(s). 1.1 Constructor (2 points) public AccountUtility(): The constructor initializes the two instance variables. 1.2 Read the given text file (10 points) public void readFile(): reads accounts.txt file and populates all account numbers into listNumbers ArrayList, and adds account numbers and corresponding CheckingAccount object as records to the LinkedHashMap object, mapNumAccounts. 1.3 Get account numbers (1 point) public ArrayList getListNumbers(): returns the instance variable, listNumbers. 1.4 Get LinkedHashMap objects (1 point) public LinkedHashMap getMapNumAccounts(): returns the instance variable, mapNumAccounts. 1.5 Save content to the text file (6 points) public void aveFile(LinkedHashMap map): the pass-in parameter is a LinkedHashMap object in which the keys are account numbers and values are CheckingAccount objects. This method writes content from the passed-in LinkedHashMap object to accounts.txt, overwrites the file's entire old content. 2. TestPart2 class (10 points) This class has the main() method. You create an AccountUtility object in this class, and use the object to test readFile() and getlistNumbers(), and use System.out.printIn() to clearly display all account numbers retrieved from the accounts. txt file. Using the above AccountUtility object to call getMapNumAccounts() method and assign the returned value to a LinkedHashMap object. You must modify balances of two different accounts from the LinkedHashMap object by calling deposit(), withdraw(), and transferTo() methods with hard-code values. You call the saveFile(LinkedHashMap) method to overwrite the accounts.txt file. The pass-in parameter is the above updated LinkedHashMap object. Notes: 1) When test your project, my accounts.txt will follow the same format as yours but have different content. 2) AccountUtility should be the only class in the project that defines methods to read from and write to the accounts.txt file. 2

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;

* @author
public class AccountUtility {

    private ArrayList<String> listNumbers;
    private LinkedHashMap<String, Account> mapNumAccounts;

    * The constructor initializes the two instance variables.
    public AccountUtility() {
       listNumbers = new ArrayList<>();
       mapNumAccounts = new LinkedHashMap<>();

    * reads accounts.txt file and populates all account numbers into
    * listNumbers ArrayList, and adds account numbers and corresponding
    * CheckingAccount object as records to the LinkedHashMap object,
    * mapNumAccounts.
    public void readFile() {
       try {
            Scanner scanner = new Scanner(new File("accounts.txt"));
            // rea line by line
            while (scanner.hasNext()) {
                String next = scanner.nextLine();
                // split line by <>
                String[] sp = next.split("<>");
                // create account
                String number = sp[0];...

By purchasing this solution you'll be able to access the following files:

50% discount

$30.00 $15.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats