Create an array of integers with 20 rows and 3 columns (each row represents a st
ID: 3690909 • Letter: C
Question
Create an array of integers with 20 rows and 3 columns (each row represents a student, and each column represents an exam score) Use nested loops to loop through each student (outer loop) and each exam score for that student (inner loop) Ask the user for the next exam score for the current student, and store it in the next spot in the array Use nested loops to print all exam scores, like this: Student 1: 90 85 72 Student 2: 82 77 65... Cone line for each of 20 students) The algorithm for printing the scores will look something like this: Loop through each student (20 students, count with i) Print the current student number Loop through each exam score (3 exams, count with j) Print the current exam score (will be at spot [i][j] in the array)Explanation / Answer
import java.util.*;
class student_score
{
public static void main(String args[])
{
int a[][]=new int[20][3];
int i,j;
Scanner scan=new Scanner(System.in);
for(i=0;i<20;i++)
{
System.out.println("Enter Data for Student"+i+1);
for(j=0;j<3;j++)
{
a[i][j]=scan.nextInt();
}
}
for(i=0;i<20;i++)
{
System.out.print("Student "+(i+1)+":");
for(j=0;j<3;j++)
{
System.out.print(a[i][j]+" ");
}
System.out.println();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.