SlideShare a Scribd company logo
1 of 3
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

More Related Content

More from Blake0FxCampbelld

import os import matplotlib-pyplot as plt import pandas as pd import r.docx
import os import matplotlib-pyplot as plt import pandas as pd import r.docximport os import matplotlib-pyplot as plt import pandas as pd import r.docx
import os import matplotlib-pyplot as plt import pandas as pd import r.docx
Blake0FxCampbelld
 
import java-util--- import java-io--- class Vertex { -- Constructo.docx
import java-util--- import java-io---   class Vertex {   -- Constructo.docximport java-util--- import java-io---   class Vertex {   -- Constructo.docx
import java-util--- import java-io--- class Vertex { -- Constructo.docx
Blake0FxCampbelld
 
Implement these classes and a interface in 3 Java programs- Class 1- T.docx
Implement these classes and a interface in 3 Java programs- Class 1- T.docxImplement these classes and a interface in 3 Java programs- Class 1- T.docx
Implement these classes and a interface in 3 Java programs- Class 1- T.docx
Blake0FxCampbelld
 
Implement the following in my java program which is written under the.docx
Implement the following in my java program which is written under the.docxImplement the following in my java program which is written under the.docx
Implement the following in my java program which is written under the.docx
Blake0FxCampbelld
 

More from Blake0FxCampbelld (20)

In a large population- 51- of the people have been vaccinated- If 4 pe.docx
In a large population- 51- of the people have been vaccinated- If 4 pe.docxIn a large population- 51- of the people have been vaccinated- If 4 pe.docx
In a large population- 51- of the people have been vaccinated- If 4 pe.docx
 
In a geographic isolate- a small population has been studied for a gen.docx
In a geographic isolate- a small population has been studied for a gen.docxIn a geographic isolate- a small population has been studied for a gen.docx
In a geographic isolate- a small population has been studied for a gen.docx
 
In a democracy- politicians may be shortsighted because they want to w.docx
In a democracy- politicians may be shortsighted because they want to w.docxIn a democracy- politicians may be shortsighted because they want to w.docx
In a democracy- politicians may be shortsighted because they want to w.docx
 
In a certain city- the daily consumption of water (in millions of lite.docx
In a certain city- the daily consumption of water (in millions of lite.docxIn a certain city- the daily consumption of water (in millions of lite.docx
In a certain city- the daily consumption of water (in millions of lite.docx
 
In a certain geographic location 15- of individuals have disease A- 15.docx
In a certain geographic location 15- of individuals have disease A- 15.docxIn a certain geographic location 15- of individuals have disease A- 15.docx
In a certain geographic location 15- of individuals have disease A- 15.docx
 
In 2014- the General Social Survey incuded a question about the role o.docx
In 2014- the General Social Survey incuded a question about the role o.docxIn 2014- the General Social Survey incuded a question about the role o.docx
In 2014- the General Social Survey incuded a question about the role o.docx
 
In 1993- when Fischer began his tenure at Kodak- the film industry was.docx
In 1993- when Fischer began his tenure at Kodak- the film industry was.docxIn 1993- when Fischer began his tenure at Kodak- the film industry was.docx
In 1993- when Fischer began his tenure at Kodak- the film industry was.docx
 
In search engines analyzes the sequences of search queries to identif.docx
In  search engines analyzes the sequences of search queries to identif.docxIn  search engines analyzes the sequences of search queries to identif.docx
In search engines analyzes the sequences of search queries to identif.docx
 
import os import matplotlib-pyplot as plt import pandas as pd import r.docx
import os import matplotlib-pyplot as plt import pandas as pd import r.docximport os import matplotlib-pyplot as plt import pandas as pd import r.docx
import os import matplotlib-pyplot as plt import pandas as pd import r.docx
 
import java-util--- import java-io--- class Vertex { -- Constructo.docx
import java-util--- import java-io---   class Vertex {   -- Constructo.docximport java-util--- import java-io---   class Vertex {   -- Constructo.docx
import java-util--- import java-io--- class Vertex { -- Constructo.docx
 
Implementing AES- Native Instructions (AES-NI) is faster than other im.docx
Implementing AES- Native Instructions (AES-NI) is faster than other im.docxImplementing AES- Native Instructions (AES-NI) is faster than other im.docx
Implementing AES- Native Instructions (AES-NI) is faster than other im.docx
 
Implement these classes and a interface in 3 Java programs- Class 1- T.docx
Implement these classes and a interface in 3 Java programs- Class 1- T.docxImplement these classes and a interface in 3 Java programs- Class 1- T.docx
Implement these classes and a interface in 3 Java programs- Class 1- T.docx
 
Implement the following in my java program which is written under the.docx
Implement the following in my java program which is written under the.docxImplement the following in my java program which is written under the.docx
Implement the following in my java program which is written under the.docx
 
Immature neutrophils released from the bone marrow in response to infe.docx
Immature neutrophils released from the bone marrow in response to infe.docxImmature neutrophils released from the bone marrow in response to infe.docx
Immature neutrophils released from the bone marrow in response to infe.docx
 
Imagine you have a gram negative pathogen that uses many different sec.docx
Imagine you have a gram negative pathogen that uses many different sec.docxImagine you have a gram negative pathogen that uses many different sec.docx
Imagine you have a gram negative pathogen that uses many different sec.docx
 
If the probability density function of a continuous random variable X.docx
If the probability density function of a continuous random variable X.docxIf the probability density function of a continuous random variable X.docx
If the probability density function of a continuous random variable X.docx
 
Imagine I conduct a study in which I test the effectiveness of music l.docx
Imagine I conduct a study in which I test the effectiveness of music l.docxImagine I conduct a study in which I test the effectiveness of music l.docx
Imagine I conduct a study in which I test the effectiveness of music l.docx
 
Imagine that a mutant strain of Drosophila undergoes crossing over at.docx
Imagine that a mutant strain of Drosophila undergoes crossing over at.docxImagine that a mutant strain of Drosophila undergoes crossing over at.docx
Imagine that a mutant strain of Drosophila undergoes crossing over at.docx
 
If the Italian Lira is trading at $1-44- what is the Indirect quote of.docx
If the Italian Lira is trading at $1-44- what is the Indirect quote of.docxIf the Italian Lira is trading at $1-44- what is the Indirect quote of.docx
If the Italian Lira is trading at $1-44- what is the Indirect quote of.docx
 
iill (Click the icon to view the dats) Requirements a- FIFO b- Woghtod.docx
iill (Click the icon to view the dats) Requirements a- FIFO b- Woghtod.docxiill (Click the icon to view the dats) Requirements a- FIFO b- Woghtod.docx
iill (Click the icon to view the dats) Requirements a- FIFO b- Woghtod.docx
 

Recently uploaded

MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MysoreMuleSoftMeetup
 

Recently uploaded (20)

Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 

Implement the Plates class buildMap function so that it populates the.docx

  • 1. 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...
  • 2. } 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
  • 3. */ } } 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