Question
PLEASE INCLUDE AN IMAGE OF THE RAPTOR FLOW CHART Objective: Use arrays to process voting data. Program Steps: Ask for the number of candidates participating
PLEASE INCLUDE AN IMAGE OF THE RAPTOR FLOW CHART
Objective: Use arrays to process voting data.
Program Steps:
Ask for the number of candidates participating in a local election.
Check to make sure the number of candidates entered by the user is 1 or more.
Ask the user to enter the last names of a series of candidates and the number of votes received by each candidate stored in two arrays. One array holds the name of the candidates, and the other holds the number of votes they received. These are considered parallel arrays.
After all data has been entered, display the name and the number of votes, one per line.
Calculate and display the total number of votes.
Calculate and display the percentage of the total votes received by the candidate. Percentage is calculated by dividing each vote by the total number of votes multiplied by 100. Use an array to hold the percentage of votes.
Find and display the winner of the election along with the number of votes received.
Discussion:
In order to find the candidate with the most wins, you can find the highest value in the array of votes and use its index to identify the candidate with the highest vote. There is an example of this algorithm in the power point slides.
I am also asking for code documentation. Your program must contain several comment lines at key steps of the program and the following comment header information:
Your name: Course number and course section: Date of completion: The time it took you to complete this exercise: Brief explanation of the program:
Dont worry about the formatting of the output with a set number of digits after the decimal point.
Submitting the assignment:
Submit your Raptor program file using the file name format:
firstNameLastNameCIT129_hw5.rap
The following is a sample run of the code. Your processing must be similar to the sample run. You still need to fully test your code.
Sample run: Enter the number of candidates: -1 Error try again: 0 Error try again: 3 Enter the name of a candidate: Fish Enter the number of Votes: 5000 Enter the name of a candidate: Shark Enter the number of Votes: 4000 Enter the name of a candidate: Duck Enter the number of Votes: 6000 *** Election Results *** Fish 5000 Shark 4000 Duck 6000 Total number of votes: 15000 *** Election Results with percentage *** Candidate Votes Received % of Total Votes Fish 5000 33.33 Shark 4000 26.66 Duck 6000 40.00 The winner of the election is Duck with 6000 votes.
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