Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

It keeps saying the system cannot find the file specified. Its referring to the txt file I have and it's not seeing it? Is there

It keeps saying the system cannot find the file specified. Its referring to the txt file I have and it's not seeing it? Is there a command I need to write to make it see the txt file

package edu.ilstu; import java.util.*; import java.io.*; class Golf { public static int temp; public static Integer[] golf = new Integer[6]; public static Integer[] player = new Integer[6]; public static int score = 0; public static void main (String [] args) throws IOException { int temp; Integer[] golf = new Integer[6]; Integer[] player =new Integer[6]; int score = 0; Scanner fileScan = new Scanner(new File("golfScores.txt")); golf[0]=new Integer(0); golf[1]=new Integer(0); golf[2]=new Integer(0); golf[3]=new Integer(0); golf[4]=new Integer(0); golf[5]=new Integer(0); System.out.println("Hole\tPar\tScores\tPlayer 1/tPlayer 2\tPlayer 3\tPlayer 4"); for(int i=1;i<=18;i++) { System.out.print(i+"\t"); System.out.print(fileScan.nextInt()+ "\t\t"); score = fileScan.nextInt(); golf[1]= golf[1]+score; System.out.print(score + "\t\t"); score = fileScan.nextInt(); golf[2]= golf[2]+score; System.out.print(score+"\t\t"); score = fileScan.nextInt(); golf[3]=golf[3]+score; System.out.print(score +"\t\t"); score = fileScan.nextInt(); golf [4] = golf [4]+score; System.out.print(score+"\t\t"); System.out.println(); fileScan.nextLine(); } player[1]= new Integer(golf[1]); player[2]= new Integer(golf[2]); player[3]= new Integer(golf[3]); player[4]= new Integer(golf[4]); player[5]= new Integer(golf[5]); golf[5] = golf[1].intValue()+golf[2].intValue() + golf[3].intValue()+golf[4].intValue(); for(int p = 1;p<=4;p++) { for(int i=1;i<=4;i++) { if(golf[i]>golf[i+1]); { temp = golf[i]; golf[i] = golf[i+1].intValue(); golf[i+1]=temp; } } } System.out.print(player[1]); System.out.print("Total Scores: " +golf[1]); compareScore(1,4); System.out.print(golf[2]+"\t"); compareScore(2,4); System.out.print(golf[3]+"\t"); compareScore(3,4); System.out.print(golf[4]); compareScore(4,4); } public static void compareScore(int increment, int number) { System.out.println(player[1]); for(int i=1;i<=4;i++) { try { if(player[i].equals(golf[increment])) { System.out.print(":Player"+i+",\t"); } } catch(Exception e) { }

}

} }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

State the uses of job description.

Answered: 1 week ago

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago