Question: This is all written in Java This is a two-part assignment. This is the Candidate.java file public class Candidate { // instance variables private int
This is all written in Java
This is a two-part assignment.
This is the Candidate.java file
public class Candidate { // instance variables private int numVotes; private String name;
// Constructor for objects of class Candidate public Candidate(String name, int numVotes) { // initialize instance variables this.name = name; this.numVotes = numVotes; }
public String getName() { return name; }
public int getVotes() { return numVotes; }
public void setVotes(int n) { numVotes = n; }
public void setName(String n) { name = n; }
public String toString() { return name + " received " + numVotes + " votes."; } } 
This is the second part of the Assignment.

This is the Grading Rubric for the final program.
Please have all the files separate. since I need to turn in Election Tester v1 and Election Tester v2 as well as Election Tester v3 and Election Tester v4
Instructions: Create a mock election project to demonstrate traversal algorithms to evaluate the results of a mock election with an array and ArrayList. 1. Create a folder called 07.04 Assignment in your Module 07 Assignment folder. 2. Download the Candidate.java to the newly-created folder. a. Observe the class instance variables name and numVotes. b. A constructor is provided. c. Getter and setter methods provided, as well as a toString method. 3. For this project, you will create two tester classes. One to demonstrate your algorithms with an array and the other for an ArrayList. 4. Create a class called ElectionTestervi. This will be the tester for the array version. The class needs to contain the following: a. An array containing five Candidate objects with their name and number of votes. b. A method to print the candidate names and votes that traverses through the array and prints out each element. c. A method that traverses through the array and counts the total of the votes for all the candidates. It should return that number. This method will be used by the method to print the table. d. A method called that traverses through the array and creates a table with columns for the candidate name, followed by votes received, and then percentage of total votes. After printing the table, print a statement showing the total number of votes for the election. e. Test your methods. Your output should be similar to that shown below. 5. Now create a class ElectionTesterV2. This class will be the tester for the ArrayList version of the project. Repeat the steps above but this time using an ArrayList. Expected Output: This is a sample of the expected output. The details will vary based on design choices you make while completing the project. Bluel: Terminal Window - Module 7 X Options Raw Election Data: Tony Stark received 3691 votes. Henry Pym received 2691 votes. B---- B ---- received 1962 votes. S --- R ---- received 1491 votes. C---- D------ received 1968 votes. Election Results: % of Total Votes Recieved Candidate Votes Tony Stark Henry Pym B --- B S_--- R--- C---D---- 3691 2691 1962 1491 1968 31.27 22.80 16.62 12.63 16.67 The total number of votes is: 11803 Can only enter input while your programming Instructions: Create a mock election project to demonstrate traversal algorithms, using the results of a mock election with an arrays and ArrayList. 1. Create a folder called 07.05 Assignment in your Module 07 assignments folder. 2. Copy your ElectionTestervi.java and ElectionTesterv2.java files to the new folder. Rename V1 to V3 and V2 to V4. Be sure to update the class statement as well, to reflect the new versions. 3. Modify the ElectionTesterV3 program to include the following: a. a method that will find a particular candidate by name and change the name for that candidate. Its arguments should include the array, a name to find, and the replacement name. b. a method that will find a particular candidate by name and change the number of votes for that candidate. Its arguments should include the array, a name to find, and the replacement votes. c. a method that will find a particular candidate by name and replace both the name and number of votes for that candidate. Its arguments should include the array, a name to find, the replacement name, and the replacement votes. 4. Test your program by calling each of the methods. Be sure to print the election results after each change. See the sample output below. Clearly announce the change that should occur so someone reading your output knows which change occurred. a. change a candidate's name b. change a candidate's vote count c. change a candidate by replacing the name and number of votes 5. Now modify the ElectionTesterV4 class that uses an ArrayList to include the same functionality as the array version. Expected Output: This is a sample of the expected output. The details will vary based on design choices you make while completing the project. Blue: Terminal Window - Module 7 Options Original Results: Votes Recieved % of Total Votes Candidate Tony Stark Henry Pym Bruce Banner S--- R C ---D 751 496 303 225 81 40.46 26.72 16.33 12.12 4.36 The total number of votes is: 1856 > Votes Recieved % of Total Votes Candidate Tony Stark Henry Pym Stan Lee S--- R. C---D 751 496 303 40.46 26.72 16.33 12.12 4.36 225 81 The total number of votes is: 1856 > Votes Recieved % of Total Votes Candidate Tony Stark Henry Pym Stan Lee S_--- R__ C---- D__ 751 284 303 225 81 45.68 17.27 18.43 13.69 4.93 The total number of votes is: 1644 ALERT! This rubric covers TWO lessons. You will begin your work now and complete the full assignment in the next lesson. 07.04 Traversals Lesson Grading Rubric Points Possible Points Earned Components Comments include name, date, and purpose of the program. 1 Two tester classes properly setup for an array and ArrayList. 3 Traversal methods for printing votes, getting total, and printing election results properly written. 6 Replacement methods for replacing a name, replacing the votes, and replacing a candidate properly written. 6 Methods invoked and run properly for both an array and ArrayList. 2 Output is clearly labeled, formatted, and accurate. 3 No compiler errors. 2 No runtime errors. 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
