Assignment 1 Number of popular votes: 300 Description: In the presidential elections for the United States of America, there are two types of votes: 1. Popular votes: are simply the sum of all votes from all citizens in every state in USA. 2. Electoral votes: Each state has a number of electoral votes; this number represents the voting membership of that state in Congress i.e. the number of representatives in its U.S. Congressional delegation (a number that is directly related to the state's population of qualified citizens as determined by the US Census) plus the number of senators. The winner of the elections is the candidate that wins most of the electoral votes. This system is called the Electoral College. You can find more explanation for the electoral college here: httns://tasks.illustrativemathematics.org/content-standards/tasks/1199 Write a cpp program that contains class "candidate". A candidate has a name, number of electoral votes and number of popular votes. In your program, write a function that reads an input file containing elections results using input file stream and output to the console the name of the winner, his electoral votes and his popular votes. Your function should be prominent to faulty data; for example, if the number of votes for one of the candidates was a negative number, the function should exit and print a proper error message on the screen (You must use exceptions to do this). Input Format: The input file consists of N+1 lines. The first line contains a number N which represents the number of candidates, the second N lines contains the information about each candidate in the following format: candidate name: number of electoral votes, number of popular votes. Sample Input File: 5 Candidate1: 30, 287 Candidate2: 68, 387 Candidate3: 90, 290 Candidate4: 200, 300
Assignment 1 Number of popular votes: 300 Description: In the presidential elections for the United States of America, there are two types of votes: 1. Popular votes: are simply the sum of all votes from all citizens in every state in USA. 2. Electoral votes: Each state has a number of electoral votes; this number represents the voting membership of that state in Congress i.e. the number of representatives in its U.S. Congressional delegation (a number that is directly related to the state's population of qualified citizens as determined by the US Census) plus the number of senators. The winner of the elections is the candidate that wins most of the electoral votes. This system is called the Electoral College. You can find more explanation for the electoral college here: httns://tasks.illustrativemathematics.org/content-standards/tasks/1199 Write a cpp program that contains class "candidate". A candidate has a name, number of electoral votes and number of popular votes. In your program, write a function that reads an input file containing elections results using input file stream and output to the console the name of the winner, his electoral votes and his popular votes. Your function should be prominent to faulty data; for example, if the number of votes for one of the candidates was a negative number, the function should exit and print a proper error message on the screen (You must use exceptions to do this). Input Format: The input file consists of N+1 lines. The first line contains a number N which represents the number of candidates, the second N lines contains the information about each candidate in the following format: candidate name: number of electoral votes, number of popular votes. Sample Input File: 5 Candidate1: 30, 287 Candidate2: 68, 387 Candidate3: 90, 290 Candidate4: 200, 300
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Write a cpp program that contains class “candidate”. A candidate has a name, number of electoral votes
and number of popular votes.
In your program, write a function that reads an input file containing elections results using input file
stream and output to the console the name of the winner, his electoral votes and his popular votes.
Your function should be prominent to faulty data; for example, if the number of votes for one of the
candidates was a negative number, the function should exit and print a proper error message on the
screen (You must use exceptions to do this)
![Number of electoral votes: 200
Assignment 1
Number of popular votes: 300
Description:
In the presidential elections for the United States of America, there are two types of votes:
1. Popular votes: are simply the sum of all votes from all citizens in every state in USA.
2. Electoral votes: Each state has a number of electoral votes; this number represents the voting
membership of that state in Congress i.e. the number of representatives in its U.S.
Congressional delegation (a number that is directly related to the state's population of qualified
citizens as determined by the US Census) plus the number of senators.
The winner of the elections is the candidate that wins most of the electoral votes. This system is called
the Electoral College. You can find more explanation for the electoral college here:
https://tasks.illustrativemathematics.org/content-standards/tasks/1199
Write a cpp program that contains class "candidate". A candidate has a name, number of electoral votes
and number of popular votes.
In your program, write a function that reads an input file containing elections results using input file
stream and output to the console the name of the winner, his electoral votes and his popular votes.
Your function should be prominent to faulty data; for example, if the number of votes for one of the
candidates was a negative number, the function should exit and print a proper error message on the
screen (You must use exceptions to do this).
Input Format:
The input file consists of N+1 lines. The first line contains a number N which represents the number of
candidates, the second N lines contains the information about each candidate in the following format:
candidate name: number of electoral votes, number of popular votes.
Sample Input File:
5
Candidate1: 30, 287
Candidate2: 68, 387
Candidate3: 90, 290
Candidate4: 200, 300
Candidate5: 150, 600](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ff2ebb01e-0f1b-49ba-9855-ee0b04427cdd%2Fcca76077-5875-49ac-a035-0ab68392c3d6%2Fxt1950k_processed.png&w=3840&q=75)
Transcribed Image Text:Number of electoral votes: 200
Assignment 1
Number of popular votes: 300
Description:
In the presidential elections for the United States of America, there are two types of votes:
1. Popular votes: are simply the sum of all votes from all citizens in every state in USA.
2. Electoral votes: Each state has a number of electoral votes; this number represents the voting
membership of that state in Congress i.e. the number of representatives in its U.S.
Congressional delegation (a number that is directly related to the state's population of qualified
citizens as determined by the US Census) plus the number of senators.
The winner of the elections is the candidate that wins most of the electoral votes. This system is called
the Electoral College. You can find more explanation for the electoral college here:
https://tasks.illustrativemathematics.org/content-standards/tasks/1199
Write a cpp program that contains class "candidate". A candidate has a name, number of electoral votes
and number of popular votes.
In your program, write a function that reads an input file containing elections results using input file
stream and output to the console the name of the winner, his electoral votes and his popular votes.
Your function should be prominent to faulty data; for example, if the number of votes for one of the
candidates was a negative number, the function should exit and print a proper error message on the
screen (You must use exceptions to do this).
Input Format:
The input file consists of N+1 lines. The first line contains a number N which represents the number of
candidates, the second N lines contains the information about each candidate in the following format:
candidate name: number of electoral votes, number of popular votes.
Sample Input File:
5
Candidate1: 30, 287
Candidate2: 68, 387
Candidate3: 90, 290
Candidate4: 200, 300
Candidate5: 150, 600
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
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…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
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)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
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…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
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)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
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](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY