Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is my assignment: --------------------------------------------------- Consider the following client class: import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Set; public class PresidentsMain { public

Here is my assignment:

---------------------------------------------------

Consider the following client class:

import java.util.Collection;

import java.util.Collections;

import java.util.HashMap;

import java.util.Map;

import java.util.Set;

public class PresidentsMain {

public static void main(String[] args) {

Map PresidentsOfTheUnitedStates = new HashMap();

PresidentsOfTheUnitedStates.put("George Washington", "Unaffiliated");

PresidentsOfTheUnitedStates.put("John Adams", "Federalist");

PresidentsOfTheUnitedStates.put("Thomas Jefferson", "Democratic-Republican");

PresidentsOfTheUnitedStates.put("James Madison", "Democratic-Republican");

PresidentsOfTheUnitedStates.put("James Monroe", "Democratic-Republican");

PresidentsOfTheUnitedStates.put("John Quincy Adams", "Democratic-Republican");

PresidentsOfTheUnitedStates.put("Andrew Jackson", "Democratic");

PresidentsOfTheUnitedStates.put("Martin Van Buren", "Democratic");

PresidentsOfTheUnitedStates.put("William Henry Harrison", "Whig");

PresidentsOfTheUnitedStates.put("John Tyler", "Whig");

}

}

}

Extend given client class:

  • Implement a static method called FilterMapByValue, that takes 2 parameters:
    • Map InMap;
    • String TargetValue;

Method should print out all map elements, for which Value == TargetValue. Test the implementation by filtering PresidentsOfTheUnitedStates map so that only presidents, affiliated with Democratic-Republican party are printed. Note: use the following to iterate over a map:

for (Map.Entry Entry : InMap.entrySet())

  • Implement a method PrintValues, that prints all values for a given map (use maps values() function). Test the implementation on PresidentsOfTheUnitedStates map.
  • Implement a method PrintKeys, that prints all keys for a given map (use maps keySet() function). Test the implementation on PresidentsOfTheUnitedStates map.

------------------------------------------

I got this today and it's due tomorrow. I'm lost in this class and don't understand how to do this :(

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

More Books

Students also viewed these Databases questions

Question

2. Develop a persuasive topic and thesis

Answered: 1 week ago

Question

1. Define the goals of persuasive speaking

Answered: 1 week ago