In: Computer Science
A teacher needs list to fill student scores on five assignments.There are 15 students in her class.The students are numbered 1 through 15.Use nested for loops to print out the list for the teacher.
//Note:: You can give input the program works fine.
import java.util.*;
class Main
{
public static void main(String args[])
{
int[][] list = new int[5][15]; //array created to store scores for assignments
Scanner sc = new Scanner(System.in);
System.out.println("Filling scores of the 15 students for 5 assignments\n\n");
//for loops to take input for scores for assignments
for(int i=0;i<5;i++)
{
System.out.println("Enter scores for assignment:"+(i+1));
for(int j=0;j<15;j++)
{
System.out.println("Enter scores for student:"+(j+1));
list[i][j] = sc.nextInt();
sc.nextLine();
}
}
//for loops to print for scores for assignments
for(int i=0;i<5;i++)
{
System.out.println("Scores for assignment: "+(i+1));
for(int j=0;j<15;j++)
{
System.out.println("Scores for student: "+(j+1)+" is: "+list[i][j]);
}
}
}
}
Output::
Note:: Adding score for 5 five students for 2 assignments .(This is for reference) You can give input for the scores of 15 students for 5 assignments.
If queries Comment