Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started