Question: Java code Assessment Instructions Instructions: For this assessment, you are going to use traversal methods 1. 2. Create a folder called Assessment in your Unit

 Java code Assessment Instructions Instructions: For this assessment, you are going

to use traversal methods 1. 2. Create a folder called Assessment in

Java code

Assessment Instructions Instructions: For this assessment, you are going to use traversal methods 1. 2. Create a folder called Assessment in your Unit 6 assessments folder. Create a class called Candidate. a. Candidate will need instance variables name and numVotes (of types String 1. and int, respectively). b. Candidate will need appropriate methods and constructors. Make sure to havea toString() method that prints the name of the Candidate along with the number of votes. Save the class as Candidate java c. 3. Create a class called TestCandidate and save it as TestCandidatejava. a. Make sure that you create an array called election. Add the following 2. Candidates with their votes: Candidate Vote John Smith 5000 4000 6000 2500 1800 Mary Miller Michael Duffy Tim Robinson Joe Ashtony Create a method called printVotes() that traverses through the array and prints out each element. Create a method called getTotal() that traverses through the array and counts b. c. 3. the total of the votes for all Candidates. It should return that number d. Create a method called printResults() that traverses through the array and creates a table with columns for Candidate name, followed by votes received, and then percentage of total votes (you can round these values). Note that this method will need to call getTotal() to use in constructing the third column. After printing the table, print a line showing the total number of votes for all Candidates. Test your methods. Your output should be similar to that shown below: e

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!