Question: charityDonations is a HashMap with String key type and Integer value type, representing the name of a donor and the amount of a donation. Integer
charityDonations is a HashMap with String key type and Integer value type, representing the name of a donor and the amount of a donation. Integer numData is read from input. Complete the for loop to read numData strings from input. For each string read:
If the string is a key in charityDonations, then output the key followed by and the value associated with the key.
Otherwise, output the string followed by : not a key".
Ex: If the input is:
Tia Dax Ani
then the output is:
Tia: not a key
Dax
Ani: not a key
import java.util.Scanner;
import java.util.HashMap;
public class CharityDonations
public static void mainString args
Scanner scnr new ScannerSystemin;
HashMap charityDonations new HashMap;
String donorName;
int giftValue;
int numData;
int i;
charityDonations.putBob;
charityDonations.putPat;
charityDonations.putDax;
charityDonations.putMeg;
numData scnrnextInt;
for i ; i numData; i
Your code goes here
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
