Question: Your task is to write a program that scores a golf game of 18 holes between 2 players. The program will read a text file

Your task is to write a program that scores a golf game of 18 holes between 2 players. The program will read a text file (your choice of file name) that should contain 18 pairs of integers. Each pair represents the score of the 2 players on a single hole. Your program will: 1. Read the text file to retrieve and keep a running total of the scores for each of the 2 players. 2. Check for correct input, and identify each of the following 4 error scenarios, and print out a different error message for each type of error: a. Less than 18 pairs of integers b. Odd number of integers (hence a missing score for the second player) c. Invalid number as a score (not an integer); in this case the error message should identify the player for whom the score is invalid and include the invalid entry in the message 3. If the file is correct, print out the winner (the player with the smallest score) a. Include both scores in the winner message b. If the scores are equal, print a message to that effect and the single score that applies to both players. 4. You can ignore the situation when the file has more that the required 36 integers and simply stop when you read 36 values.

can you write this code in the java programming language please.

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!