Cheers world,
Im still having trouble with this tho, I cant get the week to start at week one without losing the values in row zero of the array, any ideas?
class WS4bQ2 { public static void main(String[] args) { int gameScore [] [] = new int [5] [2]; //declaring and setting up array int total=0,totalcol1 = 0, totalcol2 = 0,total3= 0, wins = 0; for(int week=0; week<5; week++) { for(int col=0; col<2; col++) { gameScore[week] [col] = (int)(Math.random()*100%5+1); //random number generator } }//end outer loop System.out.println(" ITB Other Total Goals");//output table header for(int week=0;week<gameScore.length;week++) { System.out.print("Week " + week +": "); for(int col=0; col<gameScore[week].length; col++)//loop to output results and keep track of total for each week { System.out.print(gameScore[week] [col] + " "); total = total + gameScore[week][col]; } System.out.print(" " + total); System.out.println(); total=0;//reset total to 0 } // close outer loop for(int week=0;week<gameScore.length; week++)// loop to check how many games ITB won { for(int col=1; col<gameScore[week].length; col++) { if(gameScore[week][0] > gameScore[week][col]) { wins++; } } //close out loop }// close inner loop for(int week=0;week<gameScore.length;week++)//loop to count total goals scored by ITB { totalcol1 = totalcol1 + gameScore[week][0]; }// close loop for(int week=0;week<gameScore.length;week++)//loop to count goals scored by other teams { totalcol2 = totalcol2 + gameScore[week][1];//total goals in 5 weeks }// clos loop total3 = totalcol1 + totalcol2; System.out.println("ITB wins: " + wins); System.out.println("ITB goals: " + totalcol1); System.out.println("Other goals: " + totalcol2); System.out.println("Total goals: " + total3); }//end main }//end class