Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

anew Eclipse project named Lab6HWLastnameFirstname. (6 pts) Suppose you are counting ballots in an election for Supreme (Yet Somehow Democratically Elected) Ruler of the Universe.

image text in transcribed

anew Eclipse project named Lab6HWLastnameFirstname. (6 pts) Suppose you are counting ballots in an election for Supreme (Yet Somehow Democratically Elected) Ruler of the Universe. Assume you have 1,000 candidates in all, each of whom is assigned a unique ID number from 0 to 999. Within a new class named BallotCounter, write a program that processes a set of ballots. The program should run by allowing the user to enter the ID number of the selected candidate on each ballot. The user should be able to do this for as many ballots as needed, until entering a negative value to exit. Upon exiting, display a list of the candidates' ID numbers and their number of votes received, but only if the candidate received at least one vote Include error checking to ensure that the user can'ttype in an ID number above 99, Below i example of what your program might look like while running (underlined parts indicate user input). Enter candidate's ID number (0-999, any negative number to exit) any negative number to exit): 0 any negative number to exit): 123 Enter candidate's ID number (0-999 Enter candidate's ID number (o-999, any negative number to exit) 5 99, any negative number to exit): 662 Enter candidate's ID number (0-9 Enter candidate's ID number (0-999, a Invalid ID nunber! Enter candidate's ID number (0-999, any negative number to exit): Enter candidate's ID number (0-999, any negative number Enter candidate's ID number (0-999, any negative Enter candidate's ID number (0-999, any negative any negative number to exit): 2342 121 number to exit): 123 candidate's ID number (0-999, any negative number to exit): 1000 to exit): 5 Invalid ID nunber Enter candidate's ID number (0-999, any negative Enter candidate's ID number (0-999, any negative number to exi number to xit): 12 Election Results Candidate 0: 1 vote (s) Candidate 5: 2 vote(s) Candidste 7: 1 vote (s) Candidate 12: 1 vote (s) Candidate 121: 1 vote(s) Candidate 123: 3 vote (s) Candidate 662: 1 vote(s)

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

Data Analytics And Quality Management Fundamental Tools

Authors: Joseph Nguyen

1st Edition

B0CNGG3Y2W, 979-8862833232

More Books

Students also viewed these Databases questions

Question

How do parent-infant attachment bonds form?

Answered: 1 week ago

Question

Are my points each supported by at least two subpoints?

Answered: 1 week ago