You must write a small application in JAVA that stores SRC candidate names and the votes they received. Your program must: 1. 2. Create an array of SRC candidate names. Populate the array with ten names. Create an array of votes. Populate the array with the number of votes for every candidate. The two arrays work in parallel. 3. 4. 5. Print the name of every candidate with his/her number of votes. Print the total number of votes casted. Add votes for a specific candidate. a.
public class SRC {
public static void main(String[] args) {
int i, j;
String[] candidateNames = { "Oliver", "George", "Harry", "Jack", "Jacob", "Noah", "Charlie", "Thomas", "Oscar",
"William" };
int votes[] = { 23, 45, 67, 95, 12, 56, 101, 4000, 99, 44 };
for (i = 0; i < candidateNames.length; i++) {
System.out.print(candidateNames[i] + " ");
}
System.out.println("\n");
for (j = 0; j < votes.length; j++)
System.out.print(" "+votes[j] + " ");
}
}
Comments
Leave a comment