Write a Java program and pseudocode for a program that inputs a student ID, clas
ID: 644496 • Letter: W
Question
Write a Java program and pseudocode for a program that inputs a student ID, classroom number, and one test score for each student in a school with 10 classrooms (numbered 1-10). Each classroom can hold up to 30 students.The scores for the test can be 1-100. The output needs to list the total points scored for each classroom. The goal is the utilize parallel arrays. I have tried starting off with a classroom for loop and then accepting the student ID and score and storing them in arrays. But I keep getting into errors that I can't get out of. Please share your ideas of how to create a program with the correct output above.
Explanation / Answer
import java.util.Scanner;
public class test{
public static void main(String args[]){
int testScore[][] = new int[10][30];
int studentID[][] = new int[10][30];
int classroomNo[][] = new int[10][30];
int classTotal[] = new int[10];
Scanner in = new Scanner(System.in);
for(int i = 0; i < 10; i++){
classTotal[i] = 0;
for(int j = 0; j < 30; j++){
System.out.println("Enter the student ID: ");
studentID[i][j] = in.nextInt();
System.out.println("Enter the classroom number: ");
classroomNo[i][j] = in.nextInt();
System.out.println("Enter the test score: ");
testScore[i][j] = in.nextInt();
classTotal[i] += testScore[i][j];
}
}
System.out.println("Classroom Total points ");
for(int i = 0; i < 10; i++){
System.out.println((i + 1) + " " + classTotal[i]);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.