GolfScores - } // determine minimum score for hole int min...

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

View Full Document Right Arrow Icon
//********************************************************************* // 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());
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
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 &lt; scores.length; ++idx) if (scores[idx] &lt; min) min = scores[idx]; int base = min - 5; System.out.print (&quot;Par:\t&quot; + scores [0] + &quot;\t\t| &quot;); // make bars for (int count = 0; count &lt; scores[0]-base; ++count) System.out.print (&quot;*&quot;); System.out.println (); for (int player = 1; player &lt; 5; ++player) { System.out.print (&quot;P&quot; + player + &quot;:\t&quot; + scores[player] + &quot;\t&quot; + (scores[player] - scores [0]) + &quot;\t| &quot;); for (int count = 0; count &lt; scores[player]-base; ++count) System.out.print (&quot;*&quot;); System.out.println (); } } catch (Exception e) { e.printStackTrace (System.err); System.out.println (&quot;Usage: java GolfScores filename&quot;); } } }...
View Full Document

Page1 / 2

GolfScores - } // determine minimum score for hole int min...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online