Question: JAVA The code will be written in accordance with the second image Download the poll.txt, and the Election,java Open Election.java and write a method to

JAVA
The code will be written in accordance with the second image  JAVA The code will be written in accordance with the second
image Download the poll.txt, and the Election,java Open Election.java and write a

Download the poll.txt, and the Election,java Open Election.java and write a method to read poll.txt of poll data. - Each line in the poll.txt is formatted as follows: State Obi Wan\% Darth Vader\% ElectoralVotes Pollster MO 484611 Oct Zogby MT 44403 Oct Montana State U. NE 3756.5 Sep Rasmussen NV 48445 Oct Zogby - Each line represents the poll results from each state. For example, MO is the state name followed by 48 (Obi Wan votes), 46 (Darth Vader voites). In MO, Obi Wan wins the state, hence 11 electoral votes will be added for Obi Wan. - In NE, Obi Wan 37 vs Darth Vader 56, hence add 5 electoral votes for Darth Vader. - If there's a tie, no electoral vote should be awarded. - Line based scanning is required for this assignment. - The method should print how many electoral votes each candidate leads in. Sample output is as follows: pubile static void main (String [] args) I try 1 // open the file Scanner input = new Scanner (new File ("hamiet. txt")); int 1 ineNumber =0 while (input, hasNextine ()) i / 1 read a 1 ine String s= input. nextine () ; 1 ineNumberti 1/ process the line Scanner linescan = new Scanner (5); int count =0; while (1inescan.hasNext()) i inescan. next () ; // consume the input coun t+; 1 System. out.println ("tasne " + lineNumber + Nhasin+ count + "cokens ") + 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!