Getting the percentage of values in an array (Java) -


for assignment, user enter in 8 scores home team, , 8 opponent team. park of assignment requires output display number of games home team 1 , winning percentage of entire season home team. code follows: btw there lot more steps , methods required assignment, working perfectly, step/ method not.

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);     (int t = 0; t < 8; t++){         system.out.println("score game " + (t + 1) + ": ");         system.out.println(" please enter in houston texans'score: ");         texansscore [t] = sc.nextint();         system.out.println(" please enter in opponents' score: ");         opponentsscore [t] = 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;         (int =0; < tgame.length; i++){             if ( tgame [i] > oppgame [i]){             array [i] = tgame[i];             won = + 1;         }             winpercent = won / 8.0 * 100.0;         }         system.out.println("the amount of games won is: " + won + "\nthe win perecntage is: " + winpercent + "%");         return winpercent;     } 

change won = + 1; won ++;. want increment won, not make 1 higher loop index i.


Popular posts from this blog