Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel 2024 In 7 Days

Authors: Alan Dinkins

1st Edition

B0CJ3X98XK, 979-8861224000

More Books

Students also viewed these Databases questions

Question

1. What do I want to achieve?

Answered: 1 week ago