Hi
I am trying to create an two dimensional array that will store student id and grade. The program has to set the size of the array according to the user input. Then the array should be built and finally the user should be requested to add the information for the student and the grade. All this will be stored in the array. I am not sure to figure out what is wrong here , below is my program.
Code:
public class Classavg1
{
public static void main(String[] args)
{
int stu; //The number of stu
int grd = 0;
int ID = 0;
int avg;
**Scanner object**
//Create a Scanner object for keybrd input.
Scanner keybrd = new Scanner(System.in);
//Get the number of stu.
System.out.print("How many stu are in your class? ");
stu = keybrd.nextInt();
//Create an array to hold that number of stu.
int scr[][] = new int [stu][ID];
**code to get student id and grde**
for ( int id = 0; id <scr.length; id++)
{
for (int grd = 0; grd < grd; grd++);
{
System.out.print("Enter student's ID ");
ID = keybrd.nextInt();
System.out.print("Enter Student's grdes ");
scr[id][grd] = keybrd.nextInt();
}
}
}
}
Bookmarks