IEB 2022: Crew Promotion System

HardGrade 12

XSpaceSystems keeps a roster of crew members and officers. Crew members who pass a test become officers; officers who pass are promoted up the ranks (1 Ensign, 2 Lieutenant, 3 Lt Commander, 4 Commander, 5 Captain). You need an inheritance hierarchy (Officer extends CrewMember), a manager class holding everyone in an array, and a method that processes a batch of test results and reports who got promoted. See the šŸ“„ Exam Paper tab for the verbatim question. Platform note: the original paper reads crewmembers.txt and testResults.txt from disk with a promotion rule tied to the officer's current rank band, and stamps a 'date promoted' of today's date (both make exact-output grading impossible or non-deterministic on a platform like this). Here, input comes from stdin, dates are dropped from the output entirely (the exam's own format doesn't print them either), and the promotion threshold is spelled out precisely below so it's unambiguous: • A crew member (not yet an officer) is promoted to Officer rank 1 if their score is ≄ 75. • An officer at rank R (1–4) is promoted to rank R+1 if their score is ≄ (75 + 5ƗR) — i.e. rank 1 needs ≄ 80, rank 2 needs ≄ 85, rank 3 needs ≄ 90, rank 4 needs ≄ 95. • An officer already at rank 5 (Captain) cannot be promoted further, no matter their score.

Input / Output

Input: Line 1: an integer N — number of crew records. Next N lines, one record each, '#'-separated: Crew member: <fullname>#<crewID>#<department> Officer: <fullname>#<crewID>#<department>#<rank> Next line: an integer M — number of test results. Next 2ƗM lines: crewID, then that person's score, alternating. Output: for each test result in order, one line: "Officer <name> has passed and is promoted to <title> Rank <rank>" "Crew Member <name> has passed and is promoted to <title> Rank <rank>" "Officer <name> has failed" / "Crew Member <name> has failed" "Officer <name> participated in the test" (rank-5 captains only) Then two final lines: "Number of promoted crew members: <count>" "Number of promoted officers: <count>"

Examples

Input

5
Tayla Wentzel#892#Engineering#2
Kwagga Kolisi#721#Medical
Bongi le Roux#461#Security#3
Siviwe Tywaleni#131#Medical#5
Malcolm Malherbe#279#Security
3
892
90
721
80
131
95

Expected Output

Officer Tayla Wentzel has passed and is promoted to Lt Commander Rank 3
Crew Member Kwagga Kolisi has passed and is promoted to Ensign Rank 1
Officer Siviwe Tywaleni participated in the test
Number of promoted crew members: 1
Number of promoted officers: 1

+ 1 hidden test checked on Submit.

Files

Main.java is the entry point. Add extra classes for OOP exercises — they compile together.

CrewMember.java
Loading...

Run your code to see test results here.