-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathClassPerformance.java
More file actions
50 lines (46 loc) · 1.45 KB
/
ClassPerformance.java
File metadata and controls
50 lines (46 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package arrays;
import java.util.Scanner;
public class ClassPerformance {
public static void main(String[] args) {
Scanner cp = new Scanner(System.in);
System.out.println("Enter the number of student data you want to store: ");
int n = cp.nextInt();
int[] rollNumber = new int[n];
String[] name = new String[n];
float[] percentage = new float[n];
System.out.println("Enter total number of subjects: ");
int no = cp.nextInt();
float marks[][] = new float[n][no];
System.out.println("Enter the name of "+n+" students: ");
for(int i = 0; i<n; i++) {
name[i]=cp.next();
}
System.out.println("Enter the roll number of "+n+" students: ");
for(int i = 0; i<n; i++) {
rollNumber[i]=cp.nextInt();
}
System.out.println("Enter the marks of "+n+" students of "+no+" subjects: ");
for(int i = 0; i<n; i++) {
for(int j = 0; j<no; j++) {
marks[i][j] = cp.nextFloat();
}
}
for(int i = 0; i<n; i++) {
for(int j = 0; j<no; j++) {
percentage[i] += marks[i][j];
}
percentage[i] /= no;
}
float maximumPercentage = 0,temp;
int position = 0;
for(int i = 0; i<n; i++) {
temp = percentage[i];
if(temp >= maximumPercentage) {
maximumPercentage = temp;
position = i;
}
}
System.out.println("The class topper is "+ name[position]+" roll no "+ rollNumber[position]+" with a percentage of "+ maximumPercentage+" in "+no+" subjects out of "+n+" number of students in his class. YAY!!");
cp.close();
}
}