In: Computer Science
You will need to use only two arrays: One array of type int to store all the ID's
One two‐dimensional array of type double to store all the scores for all quizzes
Note: The two dimensional array can be represented also with the rows being the students and the columns being the quizzes.
How to proceed:
1. Declare the number of quizzes as a constant, outside the main method. (Recall that identifiers for constants are all in CAPITAL_LETTERS.)
2. Ask the user how many students are in the class, so you can set the length of all the arrays.
3. Allocate 2 arrays, one one‐dimensional and the other two‐dimensional, that will store the data.
4. Use two nested FOR loops to retrieve and store all the data.
5. Use another two nested FOR loops to
a. Output the final score for each student.
b. Keep track of all scores to later compute the average for the class.
6. Calculate and Output the average for the class.
Format all floating‐point numbers to 2 decimal places.
Please leave comments on the program so i can give you a thumbs up :)!
also, this is for java language
SOURCE CODE: *Please follow the comments to better understand the code. **Please look at the Screenshot below and use this code to copy-paste. ***The code in the below screenshot is neatly indented for better understanding. import java.util.Scanner; public class StudentArrayDemo { // 1. declare the constants private static final int NUM_OF_QUIZZES=3; public static void main(String[] args) { Scanner scanner=new Scanner(System.in); // 2. Ask the user how many students are in the class, // so we can set the length of all the arrays. System.out.print("Enter how many students are in the class: "); int n=scanner.nextInt(); // 3. Allocate 2 arrays, one one‐dimensional and the other two‐dimensional, that will store the data. int[] studentIds=new int[n]; double[][] scores=new double[n][NUM_OF_QUIZZES]; // 4. Use two nested FOR loops to retrieve and store all the data. for(int i=0;i<n;i++) { System.out.print("Enter "+NUM_OF_QUIZZES+" scores for student "+(i+1)+" : "); for (int j = 0; j < NUM_OF_QUIZZES; j++) { scores[i][j]=scanner.nextDouble(); } } // 5. Use another two nested FOR loops to // //a. Output the final score for each student. //b. Keep track of all scores to later compute the average for the class. double sumOfClass=0; for(int i=0;i<n;i++) { double sum=0; for (int j = 0; j < NUM_OF_QUIZZES; j++) { sum+= scores[i][j]; } System.out.printf("Final Score for student %d is %.2f\n",(i+1),sum); sumOfClass+=sum; } // 6. Calculate and Output the average for the class. double avgOfClass=sumOfClass/(n); System.out.printf("\n\nThe Average of the class is: %.2f",avgOfClass); } }
=========