I have two arrays. In the first one I have student surnames, in second the student grades. (One surname one line with grades).My task is to find the arithmetic average for each student and print that student name and grade which have the biggest grade in array. I wrote the program which can find arithmetic average for one student and print his name and grade. Can somebody help to write another part of program? Here is text of my program:
package md4;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
String surnames[]=
{"Alksnis", "Berzinsh", "Celms", "Dadzis", "Eglitis", "Zalitis"};
int grades [][] = {
{6, 6, 7, 7, 8, 5},
{5, 6, 4, 9, 5, 7},
{6, 6, 5, 6, 6, 7},
{9, 8, 8, 9, 9, 8},
{8, 7, 7, 8, 8, 7},
{7, 5, 6, 5, 7, 6}
};
double result = 0;
int u;
double arifm;
int i=0,j=0; //i=row, j=column
Scanner input = new Scanner( System.in );
System.out.println("0. Alksnis, 1. Berzinsh, 2. Celms, 3. Dadzis, 4. Eglitis, 5. Zalitis");
// surnames
i = input.nextInt(); // read number from user
System.out.println("priekkshmetu skaits no 1-6");
u = input.nextInt(); // read number from user
for (j=0; j<u; j++) //choise how many grades
result= result + grades [i][j]; //summ of elements
arifm = result / j;
System.out.println(surnames [i]+ " arithmetic average is " +arifm );
}
}
Sorry about my English :)