Summary: Your program will read a database of people and the credentials that they have earned. Then, it will read a file of queries, telling whether or not a person holds all the credentials necessary for a job.
First, process a file of people and their credentials. Create a Map whose keys are credentials and whose values are Sets of people that hold that credential. Each line in the file contains the credentials for one person. The first token is that person's name, and the remaining tokens are the creditials held by that person. All tokens are separated by one semi-colon character.
For example, the file credentials.txt contains the following lines:
Scott;MD;LLD
Mark;ECE;MechE
Greg;CS
Rich
Don;CS;CivE
Tim;MD;CS;MechE
Victor;Astro;CivE;Sanitation
Tom;MD;CS;LLD
Jim;Plumber;Sanitation
Here, for example, line one shows that Scott should be added to
the Set of people holding an MD credential and the Set
of people holding an LLD credential.
IMPORTANT: You must create the required Map: each entry maps a credential to the Set of people holding it. DO NOT CREATE A MAP FROM EACH PERSON TO THE SET OF THEIR CREDENTIALS, which might seem more natural for this form of input. Processing the input for this problem is the harder of the two parts.
Second, print a sorted version of this Map: the credentials must be printed in alphabetical order, one per line, each followed -on the same line- by its Set of people holding that credential. The names do not have to be in alphabetical order: print them the simplest way you can in Java, since the order is not important.
For example, the file above would produce:
Astro = [Victor]
CS = [Tom, Greg, Don, Tim]
CivE = [Victor, Don]
ECE = [Mark]
LLD = [Tom, Scott]
MD = [Tom, Scott, Tim]
MechE = [Mark, Tim]
Plumber = [Jim]
Sanitation = [Jim, Victor]
If you finish this part correctly, you will at least be awarded 50% credit.
Third, process a file that contains queries about people and their posssible credentials. Each line of the file contains one query. The first token is the person's name and the remaining tokes are possible creditials for that person. The tokens are separated by one semi-colon character.
For example, the input file queries.txt contains the following
lines:
Jim;Plumber
Tom;LLD;CS;MD
Victor;Astro;CS
Tim;Astro;CS;CivE
Don;CS;CivE;Butcher
Rich;Plumber
Greg
Mark;MechE;ECE;MD;LLD
Scott;LLD;MD
Here, for example, the second line asks whether Tom hold the
credentials of LLD, CS, and MD.
For each query, look up each credential in the Map to find out whether or not the person holds it. If there is no such Set for that credential, or if the associated Set does not contain the person, then the person is not properly credentialed. The program should report each held and missing credential. Finally, it should report whether or not the person is or isn't fully credentialed: holds all the queried credentials.
The above files should produce the following output:
Jim is a Plumber
Jim is fully qualified
Tom is a LLD
Tom is a CS
Tom is a MD
Tom is fully qualified
Victor is a Astro
Victor is NOT a CS
Victor is NOT fully qualified
Tim is NOT a Astro
Tim is a CS
Tim is NOT a CivE
Tim is NOT fully qualified
Don is a CS
Don is a CivE
Don is NOT a Butcher
Don is NOT fully qualified
Rich is NOT a Plumber
Rich is NOT fully qualified
Greg is fully qualified
Mark is a MechE
Mark is a ECE
Mark is NOT a MD
Mark is NOT a LLD
Mark is NOT fully qualified
Scott is a LLD
Scott is a MD
Scott is fully qualified
Enter filename for credentials: credentials.txt Astro = [Victor] CS = [Tom, Greg, Don, Tim] CivE = [Victor, Don] ECE = [Mark] LLD = [Tom, Scott] MD = [Tom, Scott, Tim] MechE = [Mark, Tim] Plumber = [Jim] Sanitation = [Jim, Victor] Enter filename for queries: queries.txt Jim is a Plumber Jim is fully qualified Tom is a LLD Tom is a CS Tom is a MD Tom is fully qualified Victor is a Astro Victor is NOT a CS Victor is NOT fully qualified Tim is NOT a Astro Tim is a CS Tim is NOT a CivE Tim is NOT fully qualified Don is a CS Don is a CivE Don is NOT a Butcher Don is NOT fully qualified Rich is NOT a Plumber Rich is NOT fully qualified Greg is fully qualified Mark is a MechE Mark is a ECE Mark is NOT a MD Mark is NOT a LLD Mark is NOT fully qualified Scott is a LLD Scott is a MD Scott is fully qualified