There are 7 candidates in an election. Each voter is allowed one vote for the candidate of his /her choice. The vote is recorded as a number from 1-7 for each candidate respectively. There are 365 voters in all. Any vote which is not a number 1-7 is invalid and counted as a spoilt vote.

You have been commissioned to write a program to automate the computation of the winner of the election. For your task you will be provided with one input file elections.txt.

Objectives: The objectives of this assignment is for students to: Demonstrate a working knowledge of structs

In your program you are required to:

  • Create a struct to represent candidates. Your struct should have 2 fields: name which stores the candidate‚Äôs name as a char array with no more than 20 letters; and an integer votes which tracks the number of votes for this candidate.
  • You should store all candidate information in an array called electionCandidates.
  • You will be required to obtain all candidate information from a text file provided called elections.txt. This file begins with the names of the seven candidates each entered on a separate line. This is then followed by the 365 ballots cast, provided as integers 1-7. Votes will be separated by 1 or more white space.
  • Your program should have 3 functions: Initialize which initializes the candidate array Processvotes that reads the ballots from the input file and update the relevant candidate struct as each vote is read. printResults: which will print the results of the elections to the console as your program output .
  • The output of your program should include the name and number of votes cast for the winning candidate and the number of spoilt votes.
  • In the event of a tie report that there was a tie between candidates ------ and ______ who got a total of ________ votes each.
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.