Question: lodgerData is a HashMap with String key type and Character value type, representing the name and room label of a guest. Integer numToRead is read
lodgerData is a HashMap with String key type and Character value type, representing the name and room label of a guest. Integer numToRead is read from input. Then numToRead keyvalue pairs are read from input and inserted into lodgerData. Output each key in the HashMap followed by ;
Ex: If the input is:
Taj G Noa Z
then one possible output is:
All keys found: Noa; Taj;
Note: The order of the keys is not guaranteed in a HashMap.
import java.util.Scanner;
import java.util.HashMap;
public class RoomReservation
public static void mainString args
Scanner scnr new ScannerSystemin;
HashMap lodgerData new HashMap;
String guestName;
char roomLabel;
int numToRead;
int i;
numToRead scnrnextInt;
for i ; i numToRead; i
guestName scnrnext;
roomLabel scnrnextcharAt;
lodgerData.putguestName roomLabel;
System.out.printAll keys found: ;
Your code goes here
System.out.println;
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
