Write a method called classAttendence() that creates a 10-by-10 two-dimensional array and asks for user input to populate it with strings of student names. The method should not return any values.

Respuesta :

Answer:

The method written in Java is as follows:

public static void classAttendance(){

   Scanner input = new Scanner(System.in);

   String[][] names = new String[10][10];

   for(int i =0;i<10;i++){

    for(int j =0;j<10;j++){

       System.out.print("Student Name: "+(i+1)+" , "+(j+1)+": ");

       names[i][j] = input.nextLine();        

    }  

   }

}

Explanation:

This defines the classAttendance() method

public static void classAttendance(){

   Scanner input = new Scanner(System.in);

This declares the 2D array of 10 by 10 dimension as string

   String[][] names = new String[10][10];

This iterates through the rows of the array

   for(int i =0;i<10;i++){

This iterates through the columns of the array

    for(int j =0;j<10;j++){

This prompts user for student name

       System.out.print("Student Name: "+(i+1)+" , "+(j+1)+": ");

This gets the student name from the user

       names[i][j] = input.nextLine();        

    }  

   }

The method ends here

}

See attachment for complete program that include main method

Ver imagen MrRoyal