Question
Write a MATLAB function to solve the voting problem from HW4. The voting results shall be created as Sheet1 of an Excel file to be
Write a MATLAB function to solve the voting problem from HW4. The voting results shall be created as Sheet1 of an Excel file to be read by your MATLAB function. The function takes one argument which is the name of the Excel file. For 3.1.b, in addition to displaying on screen, your MATLAB function should also write the results on a new sheet of the same Excel file.
(hw4 )3.2 Programming with arrays in C (25 points) Deliverable: Code and screenshot of each run. The results from the mayors race have been reported by each precinct as follows: Precinct Candidate A Candidate B Candidate C Candidate D (1) 192 48 206 37( 2) 147 90 312 21 (3) 186 12 121 38( 4) 114 21 408 39( 5) 267 13 382 29 Write a program to do the following: a. Declare an array initialized with the number of votes from the above table. b. Compute and display the total number of votes received by each candidate and the percentage of the total votes cast. c. If any one candidate received over 50 percent of the votes, the program should display a message declaring that candidate the winner. ENEE 1530 Homework 4 Author: Ittiphong Leevongwat Page 6 of 6 d. If no candidate received 50 percent of the votes, the program should display a message declaring a runoff between the two candidates receiving the highest number of votes; the two candidates should be identified by their letter names. e. Run the program once with the data shown and once with candidate C receiving only 108 votes in Precinct 4
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