-
Notifications
You must be signed in to change notification settings - Fork 0
/
ResultDetails (1).java
97 lines (63 loc) · 1.74 KB
/
ResultDetails (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package ResultPackage;
import ResultPackage.StudentPackage.RegisterStudent;
import java.util.*;
public class ResultDetails {
public ArrayList<Float> grades;
RegisterStudent rs = new RegisterStudent();
public ResultDetails(){
rs.getInput();
rs.enterData();
}
public void enterGrade() {
Scanner sc = new Scanner(System.in);
grades = new ArrayList<>();
for ( int i = 0; i < rs.sems; i++ )
{
int tot=0;
System.out.println("Enter numbr of sub for sem " + (i + 1) );
int n=sc.nextInt();
for(int j=0;j<n;j++)
{
System.out.println("Enter crdit earned for subject " + (j + 1) );
int nc=sc.nextInt();
tot+=nc;
}
try
{
float sem_grade = tot/rs.credits.get(i);
if ( sem_grade > 10 )
throw new InvalidCGPA("SGPA exceeds 10");
else
grades.add(sem_grade);
}
catch (NumberFormatException nf)
{
System.out.println(nf.getMessage() );
}
catch ( InvalidCGPA ic )
{
System.out.println(ic.getMessage() );
}
}
}
public void display () {
System.out.println("Name: " + rs.name);
System.out.println("Branch: " + rs.branch);
System.out.println("Semester\tCredits\tSGPA ");
float total = 0;
float cred_sum = 0;
for ( int i = 0; i < rs.sems; i++ )
{
System.out.println( (i+1) + "\t" + rs.credits.get(i) + "\t" + grades.get(i));
//total = total + ( grades.get(i) * rs.credits.get(i) );
//cred_sum = cred_sum + rs.credits.get(i);
total+=grades.get(i);
}
System.out.println ("Final CGPA is :" + (total/rs.sems) );
}
}
class InvalidCGPA extends Exception {
InvalidCGPA ( String s){
super(s);
}
}