Question: JAVA PROGRAMMING Ten candidates, designated 0 to 9, are competing in a preliminary election for mayor. Write a program that counts the votes for each

JAVA PROGRAMMING

JAVA PROGRAMMING Ten candidates, designated 0 to 9, are competing in a

Ten candidates, designated 0 to 9, are competing in a preliminary election for mayor. Write a program that counts the votes for each candidate. The input to your program is a list of numbers in the range 0-9 such that a value of i signifies a vote for candidate i. Terminate the data with a flag. Use an array to keep a tally of the votes. Do not use 10 different variables. Discard all invalid votes. Output from your program should be 10 pairs (one pair per line) of the form: (candidate number, number of votes) Typical input might be: 113334 1 267902314544789034531 23412311 123-999 Enter the vote list with a 0 for candidate 0, a 1 for candidate 1. up to candidate 9, terminating the list with -999: 054333858100401237142008-999 The votes for each candidate are Candidate Votes 6 4 4 0

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!