1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Bas_tet [7]
3 years ago
12

Consider the following client class:import java.util.Collection;import java.util.Collections;import java.util.HashMap;import jav

a.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 map’s values() function). Test the implementation on PresidentsOfTheUnitedStates map.Implement a method PrintKeys, that prints all keys for a given map (use map’s keySet() function). Test the implementation on PresidentsOfTheUnitedStates map.
Computers and Technology
1 answer:
Lesechka [4]3 years ago
3 0

Answer:

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 filterMapByValue(Map<String,String> inMap, String targetValue){

           for (Map.Entry<String,String> entry : inMap.entrySet()){

                 if(targetValue.equals(entry.getValue())){

                       System.out.println(entry.getKey()+" - "+entry.getValue());

                 }

           }

     }

     public static void printValues(Map<String,String> map){

           for(String value : map.values()){

                 System.out.println(value);

           }

     }

     public static void printKeys(Map<String,String> map){

           for(String key : map.keySet()){

                 System.out.println(key);

           }

     }

     public static void main(String[] args) {

           Map<String, String> PresidentsOfTheUnitedStates = new HashMap<String, String>();

           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");

           System.out.println("Presidents of Democratic-Republican party: ");

           filterMapByValue(PresidentsOfTheUnitedStates,"Democratic-Republican");

           System.out.println();

           System.out.println("Keys: ");

           printKeys(PresidentsOfTheUnitedStates);

           System.out.println();

           System.out.println("Values: ");

           printValues(PresidentsOfTheUnitedStates);

      }

}

Explanation:

See the code above

You might be interested in
Candy Kane Cosmetics (CKC) produces Leslie Perfume, which requires chemicals and labor. Two production processes are available:
Vilka [71]

Answer:

  1. Divide the resources into three parts using the corresponding process 1, process 1, and process 2 formats to maximize the use of the resources.
  2. Get the expected revenue by calculating the product of the total perfume in ounce and the price of an ounce of perfume.
  3. Increase the advertisement hours of the product.
  4. subtract the advert fee from the generated revenue to get the actual revenue.
  5. subtract the cost of production from the actual revenue to get the actual profit.

Explanation:

The get maximum profit, all the resources must be exhausted in production. The labor is divided into a ratio of 1:1:2 ( which is 5000, 5000, 1000), while the chemical units are in the ratio of 2:2:3 (10000,10000,15000). This would produce in each individual processes; 15000, 15000 and 25000 oz, which is a total of 55000 oz of perfume.

The expected revenue is $275000. If 1000oz from the 55000oz of perfume is sold without advertisement, model Jenny's awareness of the perfume increases the demand by 200oz per hour, therefore, 24hours would field 4800oz demanded, which would only take 270 hours to distribute all remaining perfumes.

The cost of production would be $130000 for labor and chemical resources plus the advert cost of $27000 ( 270 hours by 100) which is a total cost of $157000. The actual profit is $118000 ( $275000 - $157000).

3 0
2 years ago
How does the system work for this:
Snowcat [4.5K]

Answer:

it means someone thought your response to something was helpful. :))

Explanation:

8 0
2 years ago
Read 2 more answers
2.
Masja [62]

Answer:

is this a question or not?

6 0
3 years ago
When admitting digital evidence at trial, the issue of ________ comes up when the evidence involves computer-generated records.
kari74 [83]

Answer:

When admitting digital evidence at trial, the issue of <u>Authenticity</u> comes up when the evidence involves computer-generated records.

Explanation:

The digital evidence such as video, audio or some pictures have been presented before court as evidence. The first question that may arise is related to "authenticity of the material". To authenticate that evidence court may order the forensic audit of that particular evidence.

<em>So, the issue of authenticity of evidence will arise, in case of digital evidence.</em>

5 0
3 years ago
Who develop punch card​
monitta

Explanation:

The standard punch card (for computers) was invented and developed by Herman Hollerith. But the idea of punch cards was already long invented, used to control Jacquard looms.

Jacquard looms were looms that used punch cards to control the pattern a loom weaves.

The idea of punch cards in Jacquard looms also influenced Charles Babbage, who decided to use punched cards to control the sequence of computations in his proposed analytical engine. Unlike Hollerith's cards of 50 years later, which were handled in decks like playing cards, Babbage's punched cards were to be strung together.

7 0
2 years ago
Other questions:
  • The protocol that enables computers on the Internet to communicate with one another is called _____.
    10·2 answers
  • The main devices in a rectifier are:
    14·2 answers
  • BRAINLYEST IF CORRECT!!! What is the special feature of the View Side by Side command?
    6·2 answers
  • At the frequency of 2.4 GHz what is the free-space path loss in dB.
    9·1 answer
  • _____ provides vital protection and maintenance services for system hardware and software, including enterprise computing system
    12·1 answer
  • A(n) _______________ is a collection of configuration and security settings that an administrator has created in order to apply
    14·1 answer
  • If you've finished working with a data file but intend to work on it again during your work session, which button would you use
    10·2 answers
  • Why was the tesla model s help change the was we see EV
    12·1 answer
  • Name various input and output devices used with computers.
    7·1 answer
  • Data is stored on ________ using a laser to either melt the disc material or change the color of embedded dye.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!