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
sergey [27]
3 years ago
6

Write a public static method called getPIDs that has a parameter of type Map called nameToPID (keys are student names and values

are student PIDs). It should return a HashSet containing all PIDs in nameToPID.
Computers and Technology
1 answer:
Rasek [7]3 years ago
4 0

Answer:

Java program is explained below

Explanation:

import java.util.HashSet;

import java.util.Map;

import java.util.TreeMap;

public class TruckRace1 {

   public static HashSet<String> getPIDs (Map<String,String>nameToPID ){

       HashSet<String> pidSet = new HashSet<>();

       for(String ids: nameToPID.values()){

           pidSet.add(ids);

       }

       return pidSet;

   }

   public static void main(String[] args) {

       Map<String,String> pids = new TreeMap<>();

       pids.put("John","123");

       pids.put("Jason","124");

       pids.put("Peter","125");

       pids.put("Alice","126");

       pids.put("Peny","129");

       HashSet<String> ids = getPIDs(pids);

       for(String id:ids){

           System.out.println(id);

       }

   }

}

You might be interested in
Create an application containing an array that stores 10 integers. The application should call five methods that in turn (1) dis
tensa zangetsu [6.8K]

Answer:

  1.     public class Main {
  2.    public static void main(String[] args) {
  3.        int myArray[] = {3, 7, 2, 5, 9,11, 24, 6, 10, 12};
  4.        int myArray2 [] = {1, 2, 3, 4 ,5};
  5.        displayValue(myArray);
  6.        reverseDisplay(myArray);
  7.        displaySum(myArray);
  8.        displayLess(myArray, 10);
  9.        displayHighAvg(myArray);
  10.        displayBoth(myArray, myArray2);
  11.    }
  12.    public static void displayValue(int arr[]){
  13.        for(int i = 0; i < arr.length; i++){
  14.            System.out.print(arr[i] + " ");
  15.        }
  16.        System.out.println();
  17.    }
  18.    public static void reverseDisplay(int arr[]){
  19.        for(int i = arr.length-1; i >= 0; i--){
  20.            System.out.print(arr[i] + " ");
  21.        }
  22.        System.out.println();
  23.    }
  24.    public static void displaySum(int arr[]){
  25.        int sum = 0;
  26.        for(int i = 0; i < arr.length; i++){
  27.            sum += arr[i];
  28.        }
  29.        System.out.println(sum);
  30.    }
  31.    public static void displayLess(int arr[], int limit){
  32.        for(int i = 0; i < arr.length; i++){
  33.            if(arr[i] < limit){
  34.                System.out.print(arr[i] + " ");
  35.            }
  36.        }
  37.        System.out.println();
  38.    }
  39.    public static void displayHighAvg(int arr[]){
  40.        int sum = 0;
  41.        for(int i = 0; i < arr.length; i++){
  42.            sum += arr[i];
  43.        }
  44.        double avg = sum / arr.length;
  45.        for(int i = 0; i < arr.length; i++){
  46.            if(arr[i] > avg){
  47.                System.out.print(arr[i] + " ");
  48.            }
  49.        }
  50.        System.out.println();
  51.    }
  52.    public static void displayBoth(int arr1[], int arr2 []){
  53.        for(int i = 0; i < arr2.length; i++){
  54.            for(int j = 0; j < arr1.length; j++){
  55.                if(arr1[j] == arr2[i]){
  56.                    System.out.print(arr1[j] + " ");
  57.                }
  58.            }
  59.        }
  60.        System.out.println();
  61.    }
  62. }

Explanation:

There are five methods written to solve all the problems stated in the question.

Method 1 : displayValue    (Line 15 - 21)

This is the method that take one input array and use the print() method to display the all the elements in the array.

Method 2: reverseDisplay (Line 23 - 26)

This method will take one input array and print the value in the reverse order. We just need to start with the last index when running the for-loop to print the value.

Method 3: displaySum (Line 31 - 37)

This method will take one input array and use a for-loop to calculate the total of the values in the array.

Method 4: displayLess (Line 39 - 47)

This method will take one two inputs, a array and a limit. We use the limit as the condition to check if any value less than the limit, then the value will only be printed.

Method 5: displayHighAvg (Line 50 - 64)

This method will take one input array and calculate the average. The average will be used to check if any element in the array higher than it, then the value will only be printed.

Method 6: displayBoth  (Line 66 - 75)

This method will take two input arrays and compare both of them to find out if any value appears in both input arrays and print it out.

3 0
4 years ago
A network with 10 bits remaining for the host portion will have how many usable host addresses?
makvit [3.9K]

Answer:

2^10 = 1024 addresses

Explanation:

Each bit can be either 1 or 0, and this holds true for all 10 bits. So for every bit, we choose either a 0 or a 1 (2 choices), and then do so for the remaining bits. So we have 2 * 2 * 2 * ... * 2 (10 2's) choices for all 10 bits

8 0
3 years ago
How to make a slideshow out of pictures in a folder windows not fitting to screen?
weqwewe [10]

Answer:

Windows slideshow.

Explanation:

Creating or displaying a collection of images in a windows file can be very ecstatic and it is quite possible using third party applications.

One way of creating a slideshow is using the screensaver desktop option. There are other easy ways like the wallpaper option and using powerpoint presentation.

To using the screensaver option, go to windows settings and click on personalize, here, use can select a theme or a group of image files, click on a color theme and click apply.

8 0
4 years ago
Which of the following is NOT a good way to reduce pollutants in paint shops?
Citrus2011 [14]

Automobile repair shops produce many types of waste -- some hazardous, some not necessarily hazardous but still potentially damaging to the environment if not handled properly, and all requiring proper treatment and/or disposal at significant cost to the business. A list of the types of waste that the shop owner or manager must contend with would include:

solvents (paints and paint thinners)

antifreeze

scrap metal

batteries and other auto parts

oils and oil filters

fuels of various types

acids and alkalis (contaminated rags and towels)

Whatever the nature and characteristics of the waste may be, it all has one thing in common: All waste represents loss of resources and loss of money.

4 0
3 years ago
java Consider the following problem statement. A cookie recipe calls for the following ingredients: 1.5 cups of sugar 1 cup of b
Veronika [31]

Answer:

Explanation:

The following code is written in Java. It creates a program that asks the user how many cookies they want to make. Then it adjusts the original recipe based on the ratio of the original amount of cookies it makes to the amount the user wants. Finally, passing the output of the new adjusted recipe to the user. Due to technical difficulties, I have added the code as a txt file attached below.

4 0
3 years ago
Other questions:
  • Your computer is once again out of hard drive and you want to see which folders are consuming the most space on your drive. Whic
    15·1 answer
  • Define the term entity and give an example of an entity .
    10·1 answer
  • Which computer device is used to capture or copy a photograph to place in a report?
    14·1 answer
  • Write a function called median, that takes as parameter a full, sorted array of doubles and returns the median of the list. For
    15·1 answer
  • ¿dispositivos de hardware Que permite identificar la huella digital registrada por el usuario?
    11·1 answer
  • Write a number guessing game. The game should have a default 1-100 picking system. Have the user guess the number the computer p
    12·1 answer
  • give the difference between functional and functional tools in the middle of to the circle give importance​
    10·1 answer
  • Write a C++ function, smallestIndex, that takes as parameters an int array and its size and returns the index of the first occur
    15·1 answer
  • State 2 advantages of laptops over desktop computers
    11·2 answers
  • in the topology configuration, hosts are connected to each other through a central controller which assumes all responsibility f
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!