Name: ____________________________________________________ Alpha:
_____________ Section: ________
Describe help received: _________________________________________________________________
See the bottom for how to submit your work.
Due: Before 0800 on next class day
|
For each expression denoted left, fill in the type
of the expression.
|
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 1922 and
2021.
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 the 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 3 adults and 5 children |
~/$ ./hw Filename: names2.txt 9 adults and 10 children |
~/$ ./hw Filename: badname.txt File not found! |
Submit to the submission server (due: 0800 on the next class day)
~/bin/submit -c=IC210 -p=hw10 hw.cppBring to class