Question
Something wrong with my Golf score code? Using NetBean --> Application Input : package golf; import java.io.*; import java.util.*; import java.util.Scanner; import java.util.ArrayList; public class
Something wrong with my Golf score code? Using NetBean --> Application
Input :
package golf;
import java.io.*; import java.util.*; import java.util.Scanner; import java.util.ArrayList;
public class Golf {
public static void main(String[] args) throws FileNotFoundException {
int winner = 0; int player1 = 0; int player2 = 0; int player3 = 0; int player4 = 0; int par = 0; int num; int par2 = 0; int User1 = 0; int User2 = 0; int User3 = 0; int User4 = 0; Scanner scan = new Scanner(new File("golf.txt"));
for (int i = 0; i < 18; i++) {
par = scan.nextInt(); player1 = scan.nextInt(); player2 = scan.nextInt(); player3 = scan.nextInt(); player4 = scan.nextInt(); par2 = par2 + par; User1 = User1 + player1; User2 = User2 + player2; User3 = User3 + player3; User4 = User4 + player4; }
winner = player1; num = 1; if (player2 < winner) { winner = player2; num = 2; }
if (player3 < winner) { winner = player3; num = 3; }
if (player4 < winner) { winner = player4; num = 4; } } }
output :
Exception in thread "main" java.io.FileNotFoundException: golf.txt (The system cannot find the file specified) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(FileInputStream.java:195) at java.io.FileInputStream.
How do I fix it, Thank you
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
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