Your Perfect Assignment is Just a Click Away
We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

Introduction to Computer Programming

Introduction to Computer Programming

Introduction to Computer Programming with MATLAB CEE/MAE M20

EXTRA CREDIT 1 Due: Friday, August 13th 2021, 11:59 PM

Formatting Reminder: The submitted work MUST follow the naming convention listed below.

• “LastName UID EC code.zip”

• “LastName UID EC main.m”

Submit one file to the CCLE course website a .zip file containing all of the MATLAB files written for the assignment. Remember to use good coding practices by keeping your code organized, choosing suitable variable names, and commenting where applicable. Any of your MATLAB .m files should contain a few comment lines at the top to provide the name of the script, a brief description of the function of the script, and your name and UID. Any submission that does not follow the above-mentioned format will receive severe point deductions!

1. The Ranked-Choice Vote. In class, we talked about an alternative voting system in which voters rank all the candidates in order of preference instead of supporting only a single candidate. During each round of voting, only a voter’s highest-ranked eligible candidate is con- sidered. If no candidate wins a majority, the lowest performer is eliminated from all ballots and the totals are recalculated. This process continues until cone candidate achieves a majority, i.e. > 50% of the votes. Consider the following election with 9 voters deciding between 4 candidates.

1

where voter 1’s favorite candidate is 3 and least favorite candidate is 4. After the first round of voting, candidate 2 leads with 4 votes but does not secure > 50% of the total vote. Thus, the least-popular option, candidate 1, is eliminated from all ballots and the votes are recounted. Write a script that performs this vote counting process on a large set of election data until a winner has been found.

(a) Begin by writing a function to remove a specified candidate from all ballots. This function must use exactly the specification shown below, where the function name, inputs, and outputs must be followed exactly. function votes = removeCandidate(votes,losingCandidate)

This function takes the total votes array, searches for all instances of losingCandidate (losingCandidate = 1 in the above example), and removes them from the array. Since we are assuming voters will list every candidate only once, the dimension of the votes array is updated from [N × c] to [N × c ? 1].

(b) Using your removeCandidate function, write a script to determine each win- ning candidate given the mock election results posted to CCLE (we will use the load function to access the raw data.) Your code only needs to process one set of votes per run, simply swapping the load filename between runs to generate both results. Print your results to the command window using exactly the format shown below:

1 2 3 4

Round 1 Totals: 1 4 2 2

Round 2 Totals: 0 4 3 2

Round 3 Totals: 0 4 5 0

Winning Candidate: 3

Where the candidates’ round-by-ro

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: Topnotch Essay only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Topnotch Essay are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Topnotch Essay is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Topnotch Essay, we have put in place a team of experts who answer to all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.