Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
|
|
|
For each expression denoted left, fill in the type
of the expression.
|
|
Suppose the user gives the following input to the program: 3 3Write below the output of the program, given the above input. Try it without compiling and running the code. |
hw.cpp
that reads in
names and birthdates from a given file and reports the number of
adults and children in the list.
Your program should start by asking for a filename from the command line. If the file does not exist, print an error message and exit.
Each line in the file will have a single name and birthday.
Each name is a single string, and each birthday is formatted as
MM/DD/YY , so for example the birthday 08/04/32
means August 4, 1932. You may assume that each birthday is between 1920 and
2019.
After reading in the file, your program should report the number of adults and children in the file. For the purposes of this problem, an adult is anyone born on or before 09/27/00. Anyone born after that date is considered a child. On ther right is a listing of names1.txt, along with an indication of who is an adult or a child: |
|
We provide two sample files for testing: names1.txt and names2.txt. Your program must work for any file that is correctly formatted, not just these two.
Here are some sample runs (user input in red):
~/$ ./hw Filename: names1.txt 4 adults and 4 children |
~/$ ./hw Filename: names2.txt 10 adults and 9 children |
~/$ ./hw Filename: badname.txt File not found! |
~/bin/submit -c=IC210 -p=hw10 hw.cpp