-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsgpa.java
More file actions
86 lines (83 loc) · 2.13 KB
/
sgpa.java
File metadata and controls
86 lines (83 loc) · 2.13 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
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
import java.util.Scanner;
import java.lang.Math;
class student
{
String usn,name;
int credits[];
double marks[];
int n;
double sgpa;
Scanner in=new Scanner(System.in);
void accept()
{
System.out.println("Enter the students name: ");
name=in.nextLine();
System.out.println("Enter the students USN: ");
usn=in.nextLine();
System.out.println("Enter number of subjects: ");
n=in.nextInt();
credits=new int[n];
marks=new double[n];
System.out.println("Enter details of subject: ");
for(int i=0;i<n;i++){
System.out.println("Enter credit of "+(i+1) +" subject: ");
credits[i]=in.nextInt();
System.out.println("Enter marks of "+(i+1) +" subject: ");
marks[i]=in.nextInt();
}
}
void cal()
{
int c=0,sg=0,tc=0;
for(int j=0;j<n;j++){
tc=tc+credits[j];
}
for(int i=0;i<n;i++){
if(marks[i]>=90 && marks[i]<=100)
{
c=c+(10*credits[i]);
}
else if(marks[i]>=80 && marks[i]<90)
{
c=c+(9*credits[i]);
}
else if(marks[i]>=70 && marks[i]<80)
{
c=c+(8*credits[i]);
}
else if(marks[i]>=60 && marks[i]<70)
{
c=c+(7*credits[i]);
}
else if(marks[i]>=50 && marks[i]<60)
{
c=c+(6*credits[i]);
}
else if(marks[i]>=40 && marks[i]<50)
{
c=c+(5*credits[i]);
}
else{
System.out.println("Failed in subject "+(i+1));
}
}
sgpa=(c/tc);
}
void display()
{
System.out.println(" ------------- STUDENTS DETAILS-----------");
System.out.println("USN : "+usn );
System.out.println(" NAME : "+name);
System.out.println(" SGPA : "+sgpa);
}
}
public class Main
{
public static void main(String[] args)
{
student s1=new student();
s1.accept();
s1.cal();
s1.display();
}
}