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

what is wrong or do you need more info to understand the question? In the Progra

ID: 3652412 • Letter: W

Question

what is wrong or do you need more info to understand the 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. 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. Modify and run your program with the modified definition of the function updateVotesByRegion
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;
}
}

Explanation / Answer

public class candidateType{ private int VotesByRegion; private int totalNoOfVotes; candidateType(int votesByRegion,int totalNoofVotes){ this.VotesByRegion = VotesByRegion; this.totalNoOfVotes = totalNoofVotes; } int TotalVotes(int votesByRegion,int totalNoofVotes){ this.VotesByRegion = VotesByRegion; this.totalNoOfVotes = totalNoofVotes; return totalNoOfVotes; } int calculateTotalVotes(int v){ return this.totalNoOfVotes=v; } }