Implement the Plates class buildMap function so that it populates the HashMap with the state abbreviations as keys and the counts of how many each appear in the file as values. Sometimes, the parking attendant will add special notation to help her remember something about a specific entry. There are just non alphabetic characters that she adds to the state - your program should ignore these characters so that an entry like NY* still counts toward the NY plate count. She is also very inconsistent with how she enters the plates. Sometimes she uses upper case, sometimes lowercase, and sometimes she even uses a mix. Be sure to account for this in your program. Only add information for plates in New England (Maine, New Hampshire, Vermont, Massachusetts, Rhode Island, and Connecticut). Plates.java import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; public class Plates { private Map plateMap; private Set validStates; public Plates() { plateMap = new HashMap<>(); validStates = new HashSet<>(Arrays.asList("CT", "MA", "ME", "NY", "RI", "VT")); } public void buildMap(String filePath) { // Implement me... } public void printCounts() { System.out.println("Number of Plates: " + plateMap.keySet().size()); for (Map.Entry entry : plateMap.entrySet()) System.out.printf("%s -> %s%n", entry.getKey(), entry.getValue()); } } Main.java public class Main { public static void main(String[] args) { Plates main = new Plates(); main.buildMap(); main.printCounts(); /* * The output should be: * * Number of Plates: 6 * MA -> 2 * ME -> 3 * CT -> 1 * NY -> 5 * RI -> 5 * VT -> 1 */ } } plates.txt vt ma ME nY, NY me CA nE Ct NJ- WA MA ri me ny ny NY *Nj billnye mAr $RI% Ri ir RI

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Implement the Plates class buildMap function so that it populates the HashMap with the state abbreviations as keys and the counts of how many each appear in the file as values.

Sometimes, the parking attendant will add special notation to help her remember something about a specific entry. There are just non alphabetic characters that she adds to the state - your program should ignore these characters so that an entry like NY* still counts toward the NY plate count.

She is also very inconsistent with how she enters the plates. Sometimes she uses upper case, sometimes lowercase, and sometimes she even uses a mix. Be sure to account for this in your program. 

Only add information for plates in New England (Maine, New Hampshire, Vermont, Massachusetts, Rhode Island, and Connecticut).




Plates.java

import java.util.Arrays;

import java.util.HashMap;

import java.util.HashSet;

import java.util.Map;

import java.util.Set;

 

public class Plates {

    private Map<String, Integer> plateMap;

    private Set<String> validStates;

 

    public Plates() {

        plateMap = new HashMap<>();

        validStates = new HashSet<>(Arrays.asList("CT", "MA", "ME", "NY", "RI", "VT"));

    }

 

    public void buildMap(String filePath) {

        // Implement me...

    }

 

    public void printCounts() {

        System.out.println("Number of Plates: " + plateMap.keySet().size());

 

        for (Map.Entry<String, Integer> entry : plateMap.entrySet())

            System.out.printf("%s -> %s%n", entry.getKey(), entry.getValue());

    }

}

 

Main.java

public class Main {
    public static void main(String[] args) {
        Plates main = new Plates();
        main.buildMap();
        main.printCounts();

        /*
         * The output should be:
         *
         * Number of Plates: 6
         * MA -> 2
         * ME -> 3
         * CT -> 1
         * NY -> 5
         * RI -> 5
         * VT -> 1
         */
    }
}

 

plates.txt

vt  ma ME nY, NY  me CA nE         Ct

NJ- WA MA  ri    me ny   ny   NY  *Nj  billnye



mAr $RI%

 

Ri   ir RI

 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Potential Method of Analysis
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY