Create a Java program for an electronic golf score card that

Create a Java program for an electronic golf score card that lets the user enter their score for each hole.

Keep in mind that you don\'t know all of Java yet, so you will have to keep your project simple. You want something you can complete with the Java you know.

Use any of the following up to 50 points worth

- A simple if-statement - 10 points

- A complicated if-statement with multiple conditions - 15 points

- A switch-statement - 10 points

- A loop - 10 points

- Multiple loops - 15 points

- Reading or writing a file - 10 points

- Use of simple methods without parameters or returns values - 10 points

- Use of methods with parameters or returns values - 20 points

Proper programming style including suitable comments, consistent formatting, and optimal program logic must be used throughout your program.

Solution

import java.util.Scanner;
import java.io.PrintWriter;
class Main {
public static void main(String[] args) throws Exception {
   Scanner sc = new Scanner(System.in);                       // scanner to get user input
   PrintWriter writer = new PrintWriter(\"scores.txt\", \"UTF-8\"); // PrintWriter to write input to file
   int score;
   System.out.println(\"Enter -1 to stop inputs.\");
while(true){
   System.out.print(\"Golfer Score:\");
   score = sc.nextInt();
   if(score!=-1){                   // check if score is -1
       writer.println(score);
       checkPar(score);           // call the checkPar function
   }
   else{
       break;
   }
}
sc.close();                           // close scanner
writer.close();                       // close writer.
}
public static void checkPar(int score){
   if(score>20){                               // if score is less than 20, it\'s below par
       System.out.println(\"Above Par Score\");
   }
   else if(score<20){                           // if score is greater than 20, it\'s above par
       System.out.println(\"Below Par Score\");
   }
   else{                                       // if score is equal to 20, it\'s par
       System.out.println(\"Par Score\");
   }
}
}

/*

sample output

*/

Create a Java program for an electronic golf score card that lets the user enter their score for each hole. Keep in mind that you don\'t know all of Java yet, s
Create a Java program for an electronic golf score card that lets the user enter their score for each hole. Keep in mind that you don\'t know all of Java yet, s

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site