Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

To be written in JAVA Board election needs your help to read the ballots and sum out who wins the election. Each ballot has the

To be written in JAVA

image text in transcribed

Board election needs your help to read the ballots and sum out who wins the election. Each ballot has the arrangement of a punch card, if the voter votes for a candidate; he/she fills the circle that corresponds to the candidate. The ballot will be like this: Candidate 1 Candidate 2 Candidate 3 Candidate 4 Jessica James Joan Jacob Each voter may vote for only at most two people. After reading each ballot, the result was saved in a text file for further reading and recording. The summary file is saved in the handout folder as vote.txt. Each voter's vote is represented in one line of four numbers, each number is either 1 which stands for vote for; or O which stands for vote against. For example, if the line says 0 1 0 1 it means that candidate 2 and 4 are chosen. Your job is to count the ballots and print voting result When you count, you need to do the following: 1. Store the ballots in two dimensional integer array, you may NOT process the ballot while reading the file 2. After reading, check if the ballot is valid: if more than two names are chosen, then the ballot is rendered invalid. 3. Summarize valid votes 4. State who are the winners (do NOT need to rank) 5. Count popularity vote of each candidate (invalid votes are counted) Board election needs your help to read the ballots and sum out who wins the election. Each ballot has the arrangement of a punch card, if the voter votes for a candidate; he/she fills the circle that corresponds to the candidate. The ballot will be like this: Candidate 1 Candidate 2 Candidate 3 Candidate 4 Jessica James Joan Jacob Each voter may vote for only at most two people. After reading each ballot, the result was saved in a text file for further reading and recording. The summary file is saved in the handout folder as vote.txt. Each voter's vote is represented in one line of four numbers, each number is either 1 which stands for vote for; or O which stands for vote against. For example, if the line says 0 1 0 1 it means that candidate 2 and 4 are chosen. Your job is to count the ballots and print voting result When you count, you need to do the following: 1. Store the ballots in two dimensional integer array, you may NOT process the ballot while reading the file 2. After reading, check if the ballot is valid: if more than two names are chosen, then the ballot is rendered invalid. 3. Summarize valid votes 4. State who are the winners (do NOT need to rank) 5. Count popularity vote of each candidate (invalid votes are counted)

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

Intelligent Information And Database Systems Third International Conference Achids 2011 Daegu Korea April 2011 Proceedings Part 2 Lnai 6592

Authors: Ngoc Thanh Nguyen ,Chong-Gun Kim ,Adam Janiak

2011th Edition

3642200419, 978-3642200410

More Books

Students also viewed these Databases questions