Question: C++ Program: To combat election fraud, your city is instituting a new voting procedure. The ballot has a letter associated with every selection a voter

C++ Program:

To combat election fraud, your city is instituting a new voting procedure. The ballot has a letter associated with every selection a voter may make. A sample ballot is shown:-

(Voter places a tick next to his or her preferred candidate, proposition and measure to indicate his/her vote)

1. VOTE FOR MAYOR

A. Pincher, Penny

B. Dover, Skip

C. Perman, Sue

2. PROPOSITION 17

D. YES

E. NO

3. MEASURE 1

F. YES

G. NO

4. MEASURE 2

H. YES

I NO

After submitting the ballot, every voter receives a receipt that has a unique ID number and a record of the voting selections. For example, a voter who submits a vote for Sue, Perman, Yes on Proposition 17, No on Measure 1 and Yes on Measure 2 might receive a receipt with:-

ID 4925 : CDGH

The next day, the city posts all votes on its web page sorted by ID Number. This allows a voter to confirm their submission and allows anyone to count the vote totals for themselves. A sample list of for the sample ballot is shown below:-

ID VOTES
4925 CDGH
4926 AEGH
4927 CDGI
4928 BEGI
4929 ADFH

Write a program that reads the posted voting list from a file named List.txt and outputs the percent of votes cast for each ballot item. File contains a list of Id numbers and a string containing votes (column B from the table).

Task:

Define a class named Voter that stores an individuals voting record. The class should have a constructor that takes as input a string of votes for example "CDGH", a voter Id, an accessor function(s) that return the person's Id and vote for a specific question. Store each Voter instance in an array.

Your program should iterate over the array to compute and output the percent of votes cast for each candidate, proposition and measure. It should then prompt the user to enter a voter Id, iterate over the list again to find the object with that ID and print his or her votes.

Input file:

1000 BEFI

1001 BDGH

1002 BEGH

1003 CDFH

1004 CEGH

1005 ADGI

1006 ADFH

1007 BDGI

1008 CDGI

1009 AEFH

1010 CEFI

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!