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
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
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
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)