Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Purpose: Write a program to create miniVector so you can solve the following: For this assignment, you will take the results of a recent election
Purpose: Write a program to create miniVector so you can solve the following:
For this assignment, you will take the results of a recent election in a small city and report the results in different formats.
First, you must read the results from a data file and store the values using vectors. The file has the last name of each candidate and the number of votes received on one line. There could be any number of lines in the file so the program needs to count them as it goes.
Finally, you must print the results arranged in order from the winner down to the person with the fewest votes. The report should include only the name of each candidate, the total votes received by that candidate and the percentage of the votes cast in the election for that candidate arranged in order from largest to smallest. Print the percentages with one decimal place.
Create the data file using the following records and put it into the project folder, name the file "votes.txt:
Candidate Votes
Lincoln
Parks
Shakespeare
Ghandi
Ashe
A Sample output will be sent to an output file called "votePct.txt is as follows:
Candidate Votes Received Votes
xxxxxxxxxxxx xxxx xxx
xxxxxxxxxxxx xxxx xxx
xxxxxxxxxxxx xxxx xxx
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started