java
public class bowling
{
// The following is an instance of Scanner which you will use to
// read from the user.
public Scanner file = new Scanner ("3 " +
"10 0 120 150 170 " +
"11 1 200 250 220 " +
"12 0 200 200 200 " +
"13 1 150 120 130 " +
"-99 ");
public static void main (String[] args)
{
bowling program = new bowling ();
program.run ();
}
public void run ()
{
int numOfGames;
int id;
int counter;
int gender;
int scores;
int averageScore;
int handicap;
final int difference = 200;
final double mHandicap = 0.8;
final double fHandicap = 0.75;
numOfGames = file.nextInt();
counter = 0;
while(counter < numOfGames)
{
id = file.nextInt();
while (id > 0)
{
gender = file.nextInt();
if(gender == 0)
{
scores = file.nextInt();
averageScore = scores / numOfGames;
handicap = (difference - averageScore) * mHandicap;
if(handicap < 0)
{
System.out.println ("Handicap is false");
}
}
else if(gender == 1)
{
scores = file.nextInt();
averageScore = score / numOfGames;
handicap = (difference - averageScore) * fHandicap;
if(handicap < 0)
{
System.out.println ("Handicap is false");
}
}
if (score > highestScore)
{
highestScore = score;
highestID = id;
}
id = file.nextInt();
if (id < 0)
{
System.Out.println("The highest score is " + highestID + " with a score of " + highestScore);
}
}
System.out.println("Bowler's ID\t\tAverage Score\t\tBest Game\t\tHandicap");
System.out.println(id + "\t\t" + averageScore + "\t\t" + bestGame + "\t\t" + handicap);
System.out.println(highestScoringM);
System.out.println(highestScoringF);
}
counter++;
}
}
hi. i need some help with this. all im trying to do is what i think is a selection sort (calculate averageScore, calculate a handicap, print the id, average score, best game(where they scored the best) and there handicap and sort through to get the best female and male score). im having troubles in 3 parts, won't compile because of possible loss of precision on
handicap = (difference - averageScore) * mHandicap;, not sure how to sort through to find the best scoring female and male, and how to find the players best game. Ive made several attempts at this part of the code and it just looks like complete garbage. Any help would be greatly aprreciated.
- one confused kid-
*Edited by pbl to add the code=java tag. That "might" shows the identation problem
This post has been edited by pbl: 14 Oct, 2008 - 08:47 PM