I really don't understand how to write this program using string streams. Can someone please guide me in the right direction?
Your input file will include census data. A line of the file will either describe a family, or be effectively blank; either kind of line may have a comment appended, where a comment starts with // and continues to the end of the line. A line that describes a family will have the family’s yearly income (preceded by a $) and the number of members. The income may be represented as a double; the number of members could be either represented as an int or an unsigned. The income must be in [0, 1000000], and the number of members must be in [1, 10].
Examples of legal input lines (including the blank line immediately following this line):
$50000.00 1
$0 10 // blah blah blah
// Now is the time for all good men
$1000000 10 // decimal point in income field is optional
You program is supposed to read from the input file and write to the output file. If it ever encounters an illegal input line, c&d. None of the comments in the input file are transferred to the output file.
For each family described in the input file, the output file is supposed to have a line giving the average income per family member, preceded by $.
For example, if the input file consisted of the 5 legal lines I gave above, then your output file should have the following 3 lines:
$50000
$0
$100000
As you see, the third line gives $1000000 / 10, which is $100000.
1) Get line from a file
2) Remove comments
3) create a string stream from your line
4) Read a character, double and int.
5) Confirm ranges of your variables , that a character is '&' and there is no non-whitespace characters in a line
6) output if needed.
7) repeat