Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help for a c++ assignment :( To combat election fraud, your city is instituting a new voting procedure. The ballot has a letter

I need help for a c++ assignment :(

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 Week 4 Assessments) 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.

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

From Zero To Data Hero With Chatgpt

Authors: Andrew Wu

1st Edition

B0CQRJPXD9, 979-8989523009

More Books

Students also viewed these Databases questions

Question

Listens effectively to others ideas and points of view.

Answered: 1 week ago