Answered step by step
Verified Expert Solution
Link Copied!

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 5000
Parks 2000
Shakespeare 8000
Ghandi 2500
Ashe 1750
A Sample output will be sent to an output file called "votePct.txt" is as follows:
Candidate Votes Received % Votes
xxxxxxxxxxxx xxxx xx.x
xxxxxxxxxxxx xxxx xx.x
xxxxxxxxxxxx xxxx xx.x

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_2

Step: 3

blur-text-image_3

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

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions