GolfScores

# GolfScores - determine minimum score for hole int min =...

This preview shows pages 1–2. Sign up to view the full content.

//********************************************************************* // GolfScores.java Author: Lewis and Loftus // // Solution to Programming Project 8.4 //********************************************************************* import java.io.*; import java.util.*; public class GolfScores { //----------------------------------------------------------------- // Reads golf score information and produces a summary. //----------------------------------------------------------------- public static void main (String [] args) { try { int[] scores = new int[5]; BufferedReader in = new BufferedReader ( new FileReader (new File(args[0]))); for (int hole = 0; hole < 18; hole++) { StringTokenizer read = new StringTokenizer (in.readLine()); for (int player = 0; player < 5; ++player) scores [player] += Integer.parseInt (read.nextToken());

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } // determine minimum score for hole int min = scores[0]; for (int idx = 1; idx < scores.length; ++idx) if (scores[idx] < min) min = scores[idx]; int base = min - 5; System.out.print ("Par:\t" + scores [0] + "\t\t| "); // make bars for (int count = 0; count < scores[0]-base; ++count) System.out.print ("*"); System.out.println (); for (int player = 1; player < 5; ++player) { System.out.print ("P" + player + ":\t" + scores[player] + "\t" + (scores[player] - scores [0]) + "\t| "); for (int count = 0; count < scores[player]-base; ++count) System.out.print ("*"); System.out.println (); } } catch (Exception e) { e.printStackTrace (System.err); System.out.println ("Usage: java GolfScores filename"); } } }...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern