Reputation: 1
I'm almost done with this assignment I just do not understand how to create a "Highest Score counter" that would determine the highest scoring game. Here is my program so far
import java.util.Scanner;
public class Texans {
public static void main (String [] args){
final int tGame = 8;
final int oGame = 8;
int [] texansScore;
int [] opponentsScore;;
texansScore = new int [8];
opponentsScore = new int [8];
Scanner sc = new Scanner(System.in);
for (int t = 0; t < 8; t++){
System.out.println("Score for Game " + (t + 1) + ": ");
System.out.println(" Please enter in the Houston Texans'score: ");
texansScore [t] = sc.nextInt();
}
for (int u = 0; u < 8; u++){
System.out.println("Score for Game " + (u + 1) + ": ");
System.out.println(" Please enter in the opponents score: ");
opponentsScore [u] = sc.nextInt();
}
}
dterminePercent(texansScore, opponentsScore);
}
public static double dterminePercent ( int [] tGame, int [] oppGame){
int [] array = new int [tGame.length];
double won = 0;
double winPercent = 0;
for (int i =0; i < tGame.length; i++){
if ( tGame [i] > oppGame [i]){
array [i] = tGame[i];
won = i++;
}
winPercent = won / 8.0 * 100.0;
}
System.out.println("The amount of games won is: " + won + "\nThe win perecntage is: " + winPercent + "%");
return winPercent;
}
}
also i'm getting a "Multiple markers at this line - texansScore cannot be resolved to a type - Return type for the method is missing - Syntax error on token ",", delete this token" error on
dterminePercent(texansScore, opponentsScore);
}
Here is my assigment details
*The program should print:
a) the percentage of games won by the Houston Texans,
b) the highest Houston Texans’ score and the corresponding game number,
c) the highest total score (Texans’ and Opponents’ combined) of all the games and the corresponding game number as well.*
Upvotes: 0
Views: 455
Reputation: 948
To find the highest score you could always use a copy of the scores array and use
Arrays.sort(theCopiedArrayName);
int HighScore = theCopiedArrayName[theCopiedArrayName.length];
Which would get the last array value after it has been sorted, making that value the largest. I hope this helps.
Upvotes: 1