-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQB 697.java
More file actions
54 lines (43 loc) · 1.39 KB
/
QB 697.java
File metadata and controls
54 lines (43 loc) · 1.39 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
51
52
53
54
//QB 697
import java.util.*;
class student {
int roll;
int sub1, sub2, sub3, sub4, sub5, sub6;
int SPI;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter n: ");
int n = sc.nextInt();
student[] ab = new student[n]; // Array of object
for (int i = 0; i < ab.length; i++) {
ab[i] = new student(); // Constructor object
}
for (int i = 0; i < ab.length; i++) {
ab[i].calc();
ab[i].display();
}
}
student() {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Roll No. ");
roll = sc.nextInt();
System.out.println("Enter mark for Subject 1");
sub1 = sc.nextInt();
System.out.println("Enter mark for Subject 2");
sub2 = sc.nextInt();
System.out.println("Enter mark for Subject 3");
sub3 = sc.nextInt();
System.out.println("Enter mark for Subject 4");
sub4 = sc.nextInt();
System.out.println("Enter mark for Subject 5");
sub5 = sc.nextInt();
System.out.println("Enter mark for Subject 6");
sub6 = sc.nextInt();
}
void calc() {
SPI = (sub1 * 5 + sub2 * 5 + sub3 * 5 + sub4 * 5 + sub5 * 5 + sub6 * 5) / (30 * 10);
}
void display() {
System.out.println("SPI is: " + SPI);
}
}