CODE: import java.util.*; import java.io.*; public class main {public static voi
ID: 3529690 • Letter: C
Question
CODE: import java.util.*; import java.io.*; public class main {public static void main(String[] args) throws FileNotFoundException {int n,i,j,partot=0,winner=0; int[]par=new int[18]; Scanner in=new Scanner(new File("par.txt")); for(i=0;i<18;i++) {par[i]=in.nextInt(); partot+=par[i]; } Scanner in2=new Scanner(new File("scores.txt")); n=in2.nextInt(); int [][]scores=new int[18][n]; int []total=new int[n]; System.out.print("hole par "); for(i=0;i<18;i++) {System.out.print((i+1)+" "+par[i]+" "); for(j=0;jpartot) System.out.println("player "+(i+1)+" "+(total[i]-partot)+" over"); else System.out.println("player "+(i+1)+" "+(partot-total[i])+" under"); } System.out.println("The winner is player "+(winner+1)); } } TEXT FILE 1 (par.txt): 3 3 4 4 3 2 4 5 4 5 3 4 2 3 4 5 3 4 TEXT FILE 2 (scores.txt): 2 3 3 3 4 2 3 4 4 5 6 2 3 6 3 3 2 3 3 4 4 2 4 4 5 3 5 3 4 4 7 5 5 3 3 3 4 ------- I have the program working but need help incorporating error handling. In other words, check that the data in the files is formatted in any particular way, including having bad data such as characters, missing lines, an incorrect int, or an incorrect number of inputs for a given line. I've done this with user input but am not sure how to do it with files formatted. My instructor isn't really clear on how to do this. I'm a bit confused. Any help would be appreciated thanks!Explanation / Answer
Can you give me a little explanation at what this program does? I mean, I can see it reads from two files, but either your code got corrupted here :
for(j=0;jpartot)
or you miscoded.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.