Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

****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 (file included as part of Chapter 11 contents) 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 or vector. 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions