SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,julia Lobur
Chapter:
Friends Overloaded Operators And Arrays In Classes
Exercise:
Programming Projects
Question:15 | ISBN:9780321531346 | Edition: 7

Question

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.

1. VOTE FOR MAYOR

A. Pincher, Penny

B. Dover, Skip

C. Perman, Sue

Sim Q D

Q D

= ------------------------

Video Note

Solution to

Programming

Project 11.15

CHAPTER 11 / Friends, Overloaded Operators, and Arrays in Classes

2. PROPOSITION 17

D. YES

E. NO

3. MEASURE 1

F. YES

G. NO

4. MEASURE 2

H. YES

I. NO

After submitting their ballot, every voter receives a receipt that has a

unique ID number and a record of their voting selections. For example, a

voter that submits a ballot 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 their 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 for the

sample ballot is shown.

ID VOTES

4925 CDGH

4926 AEGH

4927 CDGI

4928 BEGI

4929 ADFH

Write a program that reads the posted voting list from a file and outputs

the percent of votes cast for each ballot item. You may assume that the file

does not have any header lines. The first line will contain a voter ID and a

string representing votes. Define a class named Voter that stores an

individual’s voting record. The class should have a constructor that takes

as input a string of votes (e.g., “CDGH”), a voter ID, and 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.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Sorry the answer is not available at the moment…

If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.

Spread the 'tradition of sharing'.