Hi Friends,
I have no clue how to solve following C++ question.I am a learner.Thank you in advance.

Question -- Simulation and use of random/io libraries


A recent New York Times article featured a report on the usability, stability, and effectiveness (or lack thereof) of current electronic voting systems. By one expert's estimate, some voting
technologies have a 10% error rate, which means one in ten votes is misrecorded. This sounds alarming, but if the errors are uniformly distributed (i.e. affect each candidate with equal probability), there is some consolation in the fact that it won't alter the final outcome except in very tight races. However, it is interesting to consider what situations could produce invalid results. Consider a 1000-voter election with a single percentage point spread between two candidates, i.e. 50.5% vote for one candidate, 49.5% for the other. The voting machine makes an error 8% of the time and records a vote for the opposite candidate than intended. Is this error rate high enough to invalidate the results of the election?
With a little knowledge of statistics, it is not hard to calculate the exact probability of an invalid outcome, but it is even easier to simulate this process. Generate a sequence of 505 votes for
candidate A and 495 for candidate B where each vote has a 8% chance of being inverted when recorded. Do the vote totals result in B defeating A, despite the original intentions of the voters?
This outcome represents one trial in the simulation. If you repeat this trial many times and keep track of the results, the ratio

number of trials in which election result was invalid
---------------------------------------------------------------- x 100
total number of trials

provides an estimate of the percentage chance of an invalid election result. Write a program that prompts the user to enter the voting simulation parameters, then performs 500 simulation trials and reports the ratio calculated above. A sample run of the program is shown
below:
Enter number of voters: 10000
Enter percentage spread between candidates: .005
Enter voting error percentage: .15
Chance of an invalid election result after 500 trials = 13.4%
Your program should take care to verify the user's chosen simulation parameters are within range
(percentages must be 0 to 1.0 and number of voters should be positive) and if necessary, re-prompt
for valid input. Note that because of the randomness in the simulation, it is expected that the results
will vary from run to run.
This program will give you practice with writing functions, using parameters, and client use of the
CS106 simpio and random libraries.

As with any non-trivial problem, get out pencil and paper and start breaking the problem into smaller sub sections. Keep refining till you are at least at the level of describing each function you need - what goes in, what it does, what comes out.

This one has a few obvious big sections.
-Input - get and validate the simulation parameters.
-The simulation - how will you generate the errors and report the result
-Accumulation of results
-Ratio calculation
-Display results

Break those down further, and further...

(could you PM me contact info for your prof - I'd like to "borrow"that problem for my class use sometime!)

It's going to be tricky because we don't have access to your libraries. I'm sure they are wrappers for the standard functions but that's not a given.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.