Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need as a Java program. You are asked to write two Java programs to help election officials to tally election results. The first program is

Need as a Java program.image text in transcribedimage text in transcribedimage text in transcribed

You are asked to write two Java programs to help election officials to tally election results. The first program is used inside individual precincts to count the number of votes for each candidate. On the other hand, the second program is used to count the votes collected by the different precincts. Question 1 Assume there are two candidates for office'Polly Tichen' and 'Ernest Orator'. Write a Java program that reads a sequence of numbers from the user and the sequence of numbers terminates when - 1 is entered. The sequence of numbers read is interpreted as follows: 1 if the user is voting for Tichen. 2 if the user is voting for Orator. -1 to indicate there are no more voters. Any other input is treated as error and your program should display an error messages to notify the user. After reading all the votes, your program should print out the following: The total number of votes received overall. The total number of votes received for each candidate. The percent of votes each candidate received. A message to say who wins or if there is a tie. Sample run: Enter your vote <1 orator:2 end:-17 enter your vote end:-1><1 orator:2 end:-1><1 orator:2 end:-1><1 orator:2 end:-1><1 orator:2 end:-1><1 orator:2 end:-1><1 orator:2 end:-1 total number of votes: tichen: oraton: it is a tie. nam nt question you are asked to write another java program help officials tally election results from all precincts in the city. assume same two candidates for office- tichen and orator your take as input precincts. then asks user enter votes each candidate received precinct read inputs find candidate. should work follows: ask number. use loop where iteration reads count certain updates corresponding tallies. prints following: a. final candidateboth percent received. b. how many carried won by polly ernest ties. c. winner sample run: results: orator: winner: with tie: limit digits after decimal point order divide that votes. example i.e. or multiply result division other words equal can printed double variable using decimalformat library explained slide lecture slides. requirements t must be easy displaying appropriate prompt messages. output look attractive. programs display name. comment code. at top include name brief description what does due date. blocks indented consistently correctly. delimited opening closing curly braces. braces aligned consistently. names convey meaning. written submitted via d2l>

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

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions

Question

What will you do or say to Anthony about this issue?

Answered: 1 week ago