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 RYGB Max 2 R G Elora 1 P Felicity 3 G P Y Sam 5 YG PBR Ken 2 PG 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. When comparing candidates, instead of comparing each one to one another pick one as the highest (or best) and compare it to the others one at a time. If you find a higher (better) candidate, then set this as the one you are comparing and continue until you go through all of them. If you have problems with this then ask during class or office/tutoring hours. cdn.fbsbx.com Done 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 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. Judges.txt David 4 RYGB Max 2 R G Elora 1 P Felicity 3 G P Y Sam 5 YG PBR Ken 2 PG 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: 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.

Oh no! Our experts couldn't answer your question.

Don't worry! We won't leave you hanging. Plus, we're giving you back one question for the inconvenience.

Submit your question and receive a step-by-step explanation from our experts in as fast as 30 minutes.
You have no more questions left.
Message from our expert:
Your Visual Studio question does not match the subject you selected. Please ask a question in one of the 30+ subjects available. We've credited a question to your account.
Your Question:
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 RYGB
Max 2 R G
Elora 1 P
Felicity 3 G P Y
Sam 5 YG PBR
Ken 2 PG
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.
When comparing candidates, instead of comparing each one to
one another pick one as the highest (or best) and compare it to
the others one at a time. If you find a higher (better) candidate,
then set this as the one you are comparing and continue until you
go through all of them. If you have problems with this then ask
during class or office/tutoring hours.
Transcribed Image Text: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 RYGB Max 2 R G Elora 1 P Felicity 3 G P Y Sam 5 YG PBR Ken 2 PG 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. When comparing candidates, instead of comparing each one to one another pick one as the highest (or best) and compare it to the others one at a time. If you find a higher (better) candidate, then set this as the one you are comparing and continue until you go through all of them. If you have problems with this then ask during class or office/tutoring hours.
cdn.fbsbx.com
Done
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.
Judges.txt
David 4 RYGB
Max 2 R G
Elora 1 P
Felicity 3 G P Y
Sam 5 YG PBR
Ken 2 PG
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:
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.
Transcribed Image Text:cdn.fbsbx.com Done 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. Judges.txt David 4 RYGB Max 2 R G Elora 1 P Felicity 3 G P Y Sam 5 YG PBR Ken 2 PG 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: 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.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY