package quera; import java.util.Scanner; public class Quera { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("How many students do you have?"); int n = scanner.nextInt(); for (int i = 0 ; i < n ;i++){ System.out.println("Enter their names and the number of courses in order :"); String student1 = scanner.next(); int course = scanner.nextInt(); System.out.println("Enter her\\his scores : " ); for(int x =0 ; x < course ; x++){ int score = scanner.nextInt(); long[][] scores = new long[n][]; } } } } What I have tried: I need to save the scores in a 2D jagged array and then print them all with the average grades of each student.
long[][] scores = new long[n][]; score[i] = new long[course]; // // you now add each course score in order to the score[i] array. // you probably also need to keep a note of the course count in the array, // so you do not try and access non-existent elements later.
new long[course];
new long[course + 1];
score[i] = new long[course + 1]; score[i][0] = course; // save the count of courses for (int j = 1; j <= course; j++) { // get the score for the next course // save it in the next element score[i][j] = // the score for this course }
package quera; import java.util.Scanner; public class Quera { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("How many students do you have?"); int n = scanner.nextInt(); for (int i = 0 ; i < n ;i++){ System.out.println("Enter their names and the number of courses in order :"); String student1 = scanner.next(); int course = scanner.nextInt(); System.out.println("Enter her\\his scores : " ); long[][] scores = new long[n][]; scores[i] = new long[course]; for(int x =0 ; x < course ; x++){ } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)