You are going to write a program which calculates results and statistics on the data from Lab 7A. The program has four modes of operation:
RECENT
, which outputs the most recent person to enter data into the system.TOTAL
, which outputs the total number of people in the system.COUNT
, which counts the number of people in a certain major.WHO
, which outputs a list of the people of a certain major.
Input
The first line of input will consist of the operation mode (RECENT
,
TOTAL
, COUNT
, or WHO
).
If COUNT
is selected, the next line of input will consist of the major to count.
If WHO
is selected, the next line of input will consist of the major to lookup.
Output
Your output should consist of the data described above. This will be on a
single line except when in WHO
mode, in which each person will be on a
separate line.
Lab I/O Format
Your program should use the Lab Input/Output Format, as described below:
- When prompting for input, use the prompt string
WORD>
, whereWORD
is a single, uppercase word which describes the input. - When providing output that will be graded, start the line with
OUTPUT
. Think of this as "boxing your answer" on a math worksheet, it lets us quickly find your answer. We will ignore any lines which do not start withOUTPUT
. - You may interleave the inputs and outputs in any order you wish. For example, you might want to recieve all of your inputs (order of inputs still matters!), then print all of your outputs (order of outputs still matters!), or you might want to do input/output, input/output, etc.
Example Interaction
recent.txt
has the following contents:
Jack Rosenthal
people.txt
has the following contents:
Camp,Tracy,CS
Physics,Phillip,PH
Engineer,Edward,ME
Miner,Marvin,MN
Burro,Blaster,CS
Economist,Erica,EB
Rosenthal,Jack,CS
majors.txt
has the following contents:
CS
PH
ME
MN
CS
EB
CS
Here is the interaction when RECENT
is typed:
MODE> RECENT
OUTPUT Jack Rosenthal
Here is the interaction when TOTAL
is typed:
MODE> TOTAL
OUTPUT 7
Here is the interaction when COUNT
is typed with CS
as a parameter:
MODE> COUNT
MAJOR> CS
OUTPUT 3
Here is the interaction when WHO
is typed with CS
as a parameter (the order of the output is not important):
MODE> WHO
MAJOR> CS
OUTPUT Tracy Camp
OUTPUT Blaster Burro
OUTPUT Jack Rosenthal