-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLab_6_1.java
68 lines (45 loc) · 1.63 KB
/
Lab_6_1.java
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.util.*;
class Student{
int id_no;
int no_of_subjects_registered;
int[] subject_code;
int[] subject_credit;
char[] grad_obtained;
double spi;
public Student() {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the id no :");
id_no = sc.nextInt();
System.out.println("Enter the no of subjects registered :");
no_of_subjects_registered = sc.nextInt();
subject_code = new int[no_of_subjects_registered];
for(int i=0; i<no_of_subjects_registered;i++) {
System.out.println("Enter the subject code :");
subject_code[i] = sc.nextInt();
System.out.println("Enter the subject credit :");
subject_credit[i] = sc.nextInt();
System.out.println("Enter the grad obtained :");
grad_obtained[i] = sc.next().charAt(0);
}
}
public int calculate_spi(){
//logic for calculating
// it return nothin because the return type is void
return 0;
}
public void print_spi(double spi){
System.out.println("SPI is :" +spi);
}
}
public class Lab_6_1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the no of students :");
int n = sc.nextInt();
Student[] s1 = new Student[n];
for(int j=0; j<n;j++) {
s1[j] = new Student();
s1.print_spi(spi);
}
}
}