Skip to content

Commit 9029cd3

Browse files
Create ArraySort.java
1 parent c201297 commit 9029cd3

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

‎ArraySort.java‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import java.util.*;
2+
import java.util.Scanner;
3+
4+
public class ArraySort {
5+
public static void main(String args[]) {
6+
7+
Scanner str_sc = new Scanner(System.in);
8+
Scanner int_sc = new Scanner(System.in);
9+
System.out.println("Enter the number of Students : ");
10+
int n = int_sc.nextInt();
11+
12+
float[][] StudentMarks = new float[n][7];
13+
String[] StudentName = new String[n];
14+
15+
for(int i = 0; i < n; i++){
16+
System.out.println("\n\nEnter the Name of the Student : ");
17+
StudentName[i] = str_sc.nextLine();
18+
19+
System.out.println("Enter the Marks for 5 Subjects : ");
20+
StudentMarks[i][0] = int_sc.nextInt();
21+
StudentMarks[i][1] = int_sc.nextInt();
22+
StudentMarks[i][2] = int_sc.nextInt();
23+
StudentMarks[i][3] = int_sc.nextInt();
24+
StudentMarks[i][4] = int_sc.nextInt();
25+
26+
StudentMarks[i][5] = (StudentMarks[i][0] + StudentMarks[i][1] + StudentMarks[i][2] + StudentMarks[i][3] + StudentMarks[i][4]); // total
27+
System.out.println("Total : " + StudentMarks[i][5]);
28+
StudentMarks[i][6] = (StudentMarks[i][5]) / 5; // average
29+
System.out.println("Average : " + StudentMarks[i][6]);
30+
}
31+
System.out.println("\n\n Final Matrix : \n");
32+
System.out.println("Name Sub1 Sub2 Sub3 Sub4 Sub5 Tot Avg");
33+
34+
for(int i = 0; i < n; i++){
35+
System.out.print("\n");
36+
System.out.print(StudentName[i] + " ");
37+
for(int j = 0; j < 6; j++){
38+
System.out.print(StudentMarks[i][j] + " ");
39+
}
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)