Create a program that analyzes the results of the election.

The following is a small part of the project. We have to use basics of C++, loops, if/else, nothing really beyond functions to create this program that will analyze the results of the 2012 election with the excel files given, but before I can begin, I need to be able to use these files in the program which we were not how to use a file as part of a program in linux. I was hoping for some guidance on how to proceed or if there is an example I could look at? Any suggestions would be appreciated.



Input: You have available to you two files: elect12.csv

This file contains the popular vote results from the 2012 election. There is one row per state (including DC), and the file is sorted by state name. Each row has 5 fields in order: Popular vote for Obama Popular vote for Romney Popular vote for all other candidates Total popular vote in state The state's abbreviation The first 4 columns are integers, while the last one is a string (the string happens to be 2 characters, but that shouldn't affect you for this program). ev10.csv

This file contains the number of electoral votes in each state. Like above, each row corresponds to a state, but the file is sorted differently (by electoral vote). Each row has 2 fields in order: Number of electoral votes for state The state's abbreviation

Although you know that both files have 51 rows, your programs described below should work for an arbitrary number of rows. Thus, you may not store all the information in variables, and need to make multiple passes through the files. Obviously, your program must actually process the file and not use facts that you know happened (e.g., it shouldn't assume Obama won). Indeed, you may wish to edit the files when testing your program. However, you may assume that the two major candidates placed first and second in every state. You may also assume that the two input files are consistent - i.e., both contain the same states (though not in the same order).
Hi,

first of all please show us what code you have till now...

how to proceed or if there is an example I could look at?


http://www.cplusplus.com/reference/fstream/fstream/

start with basics
Topic archived. No new replies allowed.