Help with inFiles and Functions

I have a beginner c++ project assigned where I must prompt the user for the name of a text file and use it to output directories.


Heres the prompt:

This project requires you to prompt the user for the name of a text file, input the information from the file and use it to output a directory containing party affiliation and office locations of the members of the House of Representatives from a particular state.

The first line in the file contains the name of the state. The name may contain blanks so you will need to use getline. Each line after the first contains the following data for one representative:
<district number> <name > <party> <office building> <room number>
District number and room number are integers.
The name will be a string without blanks, listed as last name comma first name
The party will be either the character R or D.
The office building will be one of the following strings: CHOB, LHOB, or RHOB
You may assume that the data file is error free but you do not know the number of items in the file.

The output should contain:
A heading using the name of the state
The district number and the name of the representative listed as first name followed by last name
The party affiliation should be listed as either Democrat or Republican
The name of the building, the room number and the floor where the office is located
The total number of democrats and republicans from that state.


http://www.house.gov/representatives/ has information about the building names and the scheme for determining the floor where each office is located.


There are six sample data files to test your program with.
Prompt the user for the name of the input file; print an error message if the data file is missing.

Your source code should contain at least three functions in addition to the main function. Do not access global variables; pass parameters.



if anyone could give guidlines or help that would be amazing. I have been studying these topics nonstop but cannot grasp it quite yet I was just looking for guidance.
Divide the whole problem in small parts, like opening/reading file, collecting data etc.
Create your sample file and start to write code. Doesn't matter if the code looks bad or not working. Start with small.

Then post your code here, ask problems where you are stuck and we will help. Keep going this way, writing some code and asking problems until the assignment is complete.
Topic archived. No new replies allowed.