-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculating_CGPA_RECR.java
More file actions
56 lines (43 loc) · 1.87 KB
/
Calculating_CGPA_RECR.java
File metadata and controls
56 lines (43 loc) · 1.87 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
55
56
import java.util.Scanner;
public class Calculating_CGPA_RECR {
//This Section is For Converting User's Grade into point
static float GradeConversion() {
Scanner x = new Scanner(System.in);
float GradeConvert = 0.0f;
System.out.print("Enter The Subject Name : ");
String sub_name = x.nextLine();
System.out.print("Enter The Grade of "+sub_name+" : ");
String grade = x.nextLine();
switch(grade) {
case"A+" -> GradeConvert = 4.00f;
case"A" -> GradeConvert = 3.75f;
case"A-" -> GradeConvert = 3.50f;
case"B+" -> GradeConvert = 3.25f;
case"B" -> GradeConvert = 3.00f;
case"B-" -> GradeConvert = 2.75f;
case"C+" -> GradeConvert = 2.50f;
case"C" -> GradeConvert = 2.25f;
case"D" -> GradeConvert = 2.00f;
case"F" -> GradeConvert = 0.00f;
default -> System.out.println("Invalid Input !");
}
return GradeConvert;
}
public static void main (String[] args) {
Scanner x = new Scanner(System.in);
float point, total_credit = 0.0f, total_point = 0.0f;
System.out.println("This Code is Created by Student of Rangpur Engineering College");
System.out.print("Enter The Number of Total Subjects : ");
byte totalSub = x.nextByte();
for (int i = 0; i < totalSub; i++) {
float grade = GradeConversion();
System.out.print("Enter The Credit of that Subject : ");
byte credit = x.nextByte();
point = grade * credit;
total_credit += credit;
total_point += point;
}
float CGPA = total_point / total_credit;
System.out.format("Your obtained CGPA : %.3f\n",CGPA);
}
}