Answer to Question #223477 in Java | JSP | JSF for All

Question #223477

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.


1
Expert's answer
2021-08-05T12:31:27-0400
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] + "       ");


	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS