This assignment is primarily about parsing character and numeric
input data that is delimited; i.e., the input consists of logical tokens
that are separated by specified characters.
The input file contains raw data from a (hypothetical) roommate preferences survey. In particular, an individual may indicate a preference in one or more of nine categories (named: Wild, Pious, SportsFan, Studious, Smoker, NightOwl, Vegan, Geek, Greek). If a preference is indicated, the individual must provide a numerical rating in the range 1 to 5, and also provide an indication of the importance of the category as a numerical rating in the range 1 to 10.
You must design and implement a C++ program that will parse an input file of the form described below and produce an output file of the specified form. This assignment will be graded automatically by the Curator System (which will be used to collect most of your work in this course). Read the Student Guide to the Curator System at the Curator website (http://ei.cs.vt.edu/~eags/Curator.html) for submission information.
Note: this program must be implemented as a single C++
source file.
<ID><tab><Name>{<tab><Response Record>}+<newline>
where
| <ID> | xxx-xx-xxxx, where each x is a digit from 0-9 |
| <Name> | a sequence of 1 to 20 characters, possibly containing punctuation and spaces (but not tabs) |
| <tab> | a single tab character |
| <newline> | a single newline character |
and a <Response Record> has the form <Category>:<Importance>:<Rating>,
and
| <Category> | a sequence of 1 to 10 characters with no internal whitespace from the list given above |
| <Importance> | a positive integer in the range 1-10 |
| <Rating> | a positive integer in the range 1-5 |
Note that the fields of a response record are delimited by colons (:).
You may assume that the input file will contain tabs and colons as described. Do not assume that all the category labels that occur in the input file will be from the list given above (case sensitive); if they are not, your program should ignore that response record. You also may not assume that the integer values will be in the specified ranges; if your program encounters an out-of-range integer value, the program should ignore that response record. Each individual will always have at least one valid response record.
000-00-0001 Hokie, Joe Pious:1:1 Sports:5:5 Wild:5:1
Smoker:5:1 Geek:10:5
000-00-0002 Hoo, Haskell Wild:10:5 Smoker:5:5 Greek:10:5
Geek:10:1 SportsFan:5:5
Next your output file will contain a sequence of tables, one for each survey response record given in the input file. Delimit each table by a line of 25 plus signs, as shown. Each table should list the respondent’s name, on a line by itself. This should be followed by a listing of the categories for which the respondent provided information, listed in alphabetical order, and for each category, the product of the importance and rating given for that category.
Your program must write its output data to a file named parse.out
—
use of any other output file name will result in a score of zero.
+++++++++++++++++++++++++
Hokie, Joe
Geek
50
Pious
1
Smoker
5
Wild
5
+++++++++++++++++++++++++
+++++++++++++++++++++++++
Hoo, Haskell
Geek
10
Greek
50
Smoker
25
SportsFan 25
Wild
50
+++++++++++++++++++++++++
You will be allowed up to five submissions for this assignment. Use them wisely. Test your program thoroughly before submitting it. If you do not get a perfect score, analyze the problem carefully and test your fix before submitting again. The highest score you achieve will be counted.
// On my honor:
//
// - I have not discussed the C++ language code in my program with
// anyone other than my instructor or the teaching
assistants
// assigned to this course.
//
// - I have not used C++ language code obtained from another student,
// or any other unauthorized source, either modified
or unmodified.
//
// - If any C++ language code or documentation used in my program
// was obtained from another source, such as a text
book or course
// notes, that has been clearly noted with a proper
citation in
// the comments of my program.
//
// - I have not designed this program in such a way as to defeat
or
// interfere with the normal operation of the Automated
Grader.
Failure to include this pledge in a submission is a violation of
the Honor Code.