Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.(FileInputStream.java:138) at java.util.Scanner.(Scanner.java:611) at golf.Golf.main(Golf.java:25) C:\Users\kluser\AppData\Local\NetBeans\Cache\8.2\executor-snippets un.xml:53: Java returned: 1 BUILD FAILED (total time: 0 seconds)

How do I fix it, Thank you

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_2

Step: 3

blur-text-image_3

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

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions

Question

Write short notes on Interviews.

Answered: 1 week ago

Question

Define induction and what are its objectives ?

Answered: 1 week ago

Question

Have ground rules been established for the team?

Answered: 1 week ago

Question

a. How are members selected to join the team?

Answered: 1 week ago

Question

b. Will new members be welcomed?

Answered: 1 week ago