in a certain election ,there are seven candidates .each voter is allowed one vote for the candidate of his /her choice .The vote is recorded as a number from 1 to 7.(i.e a vote of j indictes that you are voting for candidate j where j=1,2,3......7).The number of voters is unknown beforehand but the votes are terminated by a vote of 0.Any vote ,which is not a number from 1 to 7, is an invlid vote . write a java program that reads the names of the 7 candidates ,reads the votes one at a time and evaluates the results of the election. your output should specify the total number of votes ,the number of valid and invalid votes and the winners of the election e.g When the program is run and the following data is supplied: MA pseudo code ma input 1.initialise vote and count 2.use for loop and arrays 3.if vote not (1-7);println invalid 4.if vote =0; then terminate the program ma output 1.no.of votes 2.no. of valid and invalid votes 3.winner(s) the election
import java.io.*; import java.util.ArrayList; public class amone { public static void main(String[] args)throws IOException { int j,vote;
ArrayList array = new ArrayList(); while (user still wants input) { get int for vote and put it into a variable userVote; if (j!=0) array.add(new Integer(userVote)); }