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 < 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

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

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