Question: Code must be written in Java: Write a console program in a class named Election that prompts for the name of , and then reads,
Code must be written in Java: Write a console program in a class named Election that prompts for the name of and then reads, a file of poll data about two candidates in an election. Each line of the file contains data from one state or region in the election, along with the percentage of the vote that each candidate won. The data will be provided in the following format:
State Candidate Candidate ElectoralVotes Pollster
CT Oct U of Connecticut
NE Sep Rasmussen
AZ Oct Northern Arizona U
For example, in the data above, Candidate won Connecticut with of the vote, earning electoral votes in the process. Candidate won NE and AZ earning electoral votes. And so on
Your program should prompt for the file name to read, then read its data and print how many electoral votes each candidate leads in and who is leading overall in the polls. If the two candidates tie in a given region, don't give anybody those votes.
Input file? polls.txt
Candidate : votes
Candidate : votes
You may assume that the user types the name of a file that exists and is readable, and that the data is in the valid format shown above.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
