Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need to know how I would code this in C++ This is the contents of the candidates.txt file. Instructions Write a program called voter.cpp
I need to know how I would code this in C++
This is the contents of the candidates.txt file.
Instructions Write a program called voter.cpp that uses three parallel vectors: candidates, votes and percents. They should be declared as string, int, and double, respectively. Your program should read the file candidates.txt into the vector, candidates. This file is on Canvas under the Week 8 module. The program should then fill the votes vector with random numbers between 1500 and 9000 the votes vector should be the same size as the candidates vector Determine the total number of votes for all candidates and fill the percents vector with the percentage for each candidate. Finally, print the names of the candidates, their vote totals and percentages, and the election results to both the console and an output text file. Your output file should look like your console output, e.g. Candidate Votes Percent Johnson Crosby Guffy Mancini Hong Fremont Iglesias Bronski Huffnagle Maata Malkin Polamalu 0 Brien Fahd Santini Rodriguez 4614 7725 2525 2609 6746 2446 5139 6005 3885 4853 6116 5916 3755 2993 5104 7188 5.9% 10 , 0% 3.3% 3.4% 8.7% 3.2% 6.6% 7.7% 5.8% 6.3% 7.9% 7.6% 4.8% 3.9% 6.6% 9.3% The winner is Crosby with 7725 votesStep 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