The Codemon Academy is incredibly satisfied with your work (give yourself a pat on the back...because we can’t afford to pay you anything else). So the academy wants to up their security system to
get control make students safer.
To up their security system, the academy has introduced “zones” with a sign-in system that logs the profile of the entrant as they enter the zone. A zone is a specific section of the academy. Each zone should only be entered by specific people. However, a few rascals sometimes sneak past the security guards. To catch these meddling brats, the academy has installed an entrant detection system that gives them information on each entrant. This information will be outputted to a log file which will be provided. There will be one log file for each zone.
This homework will build off the last assignment with a few additions. One of the big ones being that you will no longer be taking input from standard in (cin). Instead you will be taking input from FILES! The files can be found here under “Homework 5” on this website.
In order to get all the data, all you have to do is issue these commands from the directory in which you want the files to reside:
wget https://henrycwong.com/homework/fs2021/hw5/the_library.log wget https://henrycwong.com/homework/fs2021/hw5/training_room.log wget https://henrycwong.com/homework/fs2021/hw5/faculty_lounge.log wget https://henrycwong.com/homework/fs2021/hw5/the_chamber_of_ekans.logThe input files will be in the format:
fname lname age occupation num_of_codemon security_level
The Codemon Academy has introduced 4 different zones:
You will need to create a struct to represent the zones. To get data for each zone, each zone will have its own log file. Therefore, you will be required to read through 4 files that are provided.
Each zone and entrant will be assigned a “security level” ranging from 1-4. The Library has a security level of 1, the Training Room with a security level of 2, the Faculty Lounge with a security level of 3, and finally The Chamber of Ekans with a security of 4. The higher the number, the more strict the security is.
Each zone will also have a name and a “total number of potential violations”, which is the total number of potential violations that have occurred within that specific zone.
You are to detect whenever there is a potential violation and provide a warning in the output file.
Potential Team Picket members will now be logged as warnings, so no need to print out if a entrant was suspected to be from team Picket.
A potential violation is committed if:
To find the quartile of an array, you must:
(3/4) * (n+1) where nis the number of useful data
The number at the index calculated will be the 3rd quartile if the index started at 1.
To record these warnings. You will write to a file specifically for the zone where the potential violation occurred. Therefore, you will be writing to 4 different files, each called the_library_warnings.log, training_room_warnings.log, faculty_lounge_warnings.log, and the_chamber_of_ekans_warnings.log (if you already made your program output .txt, that's ok. But if you can change it to .log).
The warnings per zone will be placed in their respective files.
Each warning will contain the following information in order:
Classified as Student at age X
Entrant with level of Y entered a zone of level Z
Entrant has too many codemon, entrant has A codemon, the third quartile is B
Notice the format is similar to the printEntrant function in the previous homework. However, for this homework we will expect you to overload the << operator.
If one entrant has more than one warning, treat each warning as a separate entity regardless of the entrant. Therefore, there will be one warning for each recorded potential violation. The order of which the warning should be presented first is in the following order:
Therefore, in the output file, the first entrants to be listed are entrants who were over 30 and occupation was “student”. The next entrants listed will be entrants who have a security level less than the security level of the zone they entered. Finally, the last entrants listed in the output file will be entrants who had more Codemon than the 3rd quartile.
You will then have a “summary” section that will print out each zone followed by the total number of violations for that zone in descending order.
This will be what is in standard out. We will also be grading you on the output files you generate.
Summary Training Room: 7 potential violations The Chamber of Ekans: 3 potential violations The Library: 2 potential violations Faculty Lounge: 0 potential violations
Read in input from first zone Store data as appropriate For every potential violation record a warning in the output file Repeat 1-3 for every input file Print out the number of total violations per zone in descending order