Question
Jan Villaroel
Budget: $25 Subject: Others due 1 year ago
Here we will be taking data in as a file. Note that the sample file provided here is not the file that I will use to grade your assignment but the formatting will be the same.

Lab Chapter 4

Here we will be taking data in as a file. Note that the sample file provided here is not the file that I will use to grade your assignment but the formatting will be the same.
File input is very similar to how data comes in from the user through cin (using the same operators) but we will need to setup the stream ourselves.

First we need to include <fstream> at the top of our file.

We will need to create an input file stream to work from now. We will do this with ifstream. ifstream is a datatype just like int or float. Create a variable with the datatype being ifstream. We will define the variable by using the member accessor operator to call the open function and passing in “Judges.txt”, which is where our data will be.

Example: [whatever the variable name is].open(“Judges.txt”);

Your program must be setup to open “Judges.txt” as the file. For testing you can add your own Judges.txt file into visual studios or xcode as a resource. The judges file will be formatted like:

Judges.txt
David 4 R Y G B
Max 2 R G
Elora 1 P
Felicity 3 G P Y
Sam 5 Y G P B R
Ken 2 P G

There are 6 judges (each on his only line). Each judge has a been given a different number of ballots (number of votes), this is the number given after their name. The judges are voting on the candidate that they like most, and the order of their votes matter. The first vote a judge gives is worth 5 pointes, the second vote 4 points, the third 3, and so on, with the fifth vote being worth 1 point.

Each judge has a maximum of 5 votes and there are 5 candidates in the voting race. The candidates are Red, Green, Blue, Yellow, and Purple (each represented in the file by their first letter). Your job is to add up the points for each candidate and announce the winner. In order to complete this assignment you will need to use selection statements for reading the file and for comparing the candidates at the end.


Bids
Overall Details: 0 expert/s bid on this question
Answers
No answer provided for this question