Suppose a new member of the city council has to be chosen from three candidates and suppose there are 4 voting stations. We need a C++ program that will count the votes for every candidate and display the result. At every voting station the voters vote by choosing A, B or C on a ballot paper. The voting officer must enter the votes into the program so that they can be counted. X is entered when all the votes at a specific voting station have been entered. The program has the following structure: • The three totals and the number of spoilt votes are initialised to 0. Use the following integer variables votesForA, votesForB, votesForC, spoiltVotes • Use a for loop, going from 1 to the number of voting stations. • Inside this loop is a while loop. A prompting message appears on the screen, asking the voter for which candidate he or she wants to vote. The choice of the voter is then input. • Inside the while loop is a switch statement to increment the correct total. The default option is used to count the number of spoilt votes. • The while loop is exited when X is entered for the choice. • When the for loop is exited, the three totals and the number of spoilt votes are displayed. • Display the results as follows: Total candidate A: xxx Total candidate B: xxx Total candidate C: xxx Total spoilt votes: xxx Run your program with the input given below and submit printouts of the program and output. (We write the data of each voting station in one line, but you will possibly enter the values on separate lines.)  B B B A C X A B C D Y B X B A C C B X A B X Submit your program and output

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

 Suppose a new member of the city council has to be chosen from three candidates and suppose there are 4
voting stations. We need a C++ program that will count the votes for every candidate and display the
result. At every voting station the voters vote by choosing A, B or C on a ballot paper. The voting officer
must enter the votes into the program so that they can be counted. X is entered when all the votes at a
specific voting station have been entered.
The program has the following structure:
• The three totals and the number of spoilt votes are initialised to 0. Use the following integer variables
votesForA, votesForB, votesForC, spoiltVotes
• Use a for loop, going from 1 to the number of voting stations.
• Inside this loop is a while loop. A prompting message appears on the screen, asking the voter for
which candidate he or she wants to vote. The choice of the voter is then input.
• Inside the while loop is a switch statement to increment the correct total. The default option
is used to count the number of spoilt votes.
• The while loop is exited when X is entered for the choice.
• When the for loop is exited, the three totals and the number of spoilt votes are displayed.
• Display the results as follows:
Total candidate A:
xxx Total candidate
B: xxx Total
candidate C: xxx
Total spoilt votes:
xxx
Run your program with the input given below and submit printouts of the program and output. (We write the data
of each voting station in one line, but you will possibly enter the values on separate lines.) 

B B B A C X
A B C D Y B X B A C
C B X
A B X
Submit your program and output 

Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

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