Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In the Programming Exercise Election Results, the class candidatedateType contai

ID: 3648397 • Letter: I

Question

In the Programming Exercise Election Results, the class candidatedateType contains the function calculateTotalVotes. After processing the voting data, this function calculates the total number of votes received by a candidate. The function updateVotesByRegion (of the class candidateType) updates only the number of votes for a particular region.

1) Modify the definition of this function so that it also updates the total number of votes received by the candidate. By doing so, the function addVotes in the main program is no longer needed. I have the the original class candidateType.

2) Modify and run your program with the modified definition of the function updateVotesByRegion.

Explanation / Answer

class candidateType{ private int VotesByRegion; private int totalNoOfVotes; //parameterized constructor public candidateType(votesByRegion,totalNoofVotes){ this.VotesByRegion = VotesByRegion; this.totalNoOfVotes = totalNoofVotes; } //TotalVotes method public static int TotalVotes(votesByRegion,totalNoofVotes){ this.VotesByRegion = VotesByRegion; this.totalNoOfVotes = totalNoofVotes; return totalNoOfVotes; } }