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...
icon
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
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
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