Question 1: (20 marks) a) Write a method that reads candidates information from an input file, an example of which follows: 2 Trump:35:8 Biden:18:26 The
Question 1: (20 marks) a) Write a method that reads candidates information from an input file, an example of which follows: 2 Trump:35:8 Biden:18:26 The first line consists of a number that specifies how many candidates are running for the US presidential election. If that number is n, the next n lines each specify a candidate, with the candidate's name appearing on the line first, followed by a colon, and followed by the number of popular and electoral votes received by that candidate each separated by a colon. Then the method finds and returns the winner information who got the maximum electoral votes. You may assume that the input file will always be properly formatted according to this specification. (10 marks) b) Design and implement a JavaFX GUI which has a text area and a button. When the program starts up, it calls your method in (a) to read and return the winners information in an appropriate format, so once the user clicks the button, it displays the winner who got the maximum electoral votes. (10 marks)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started