-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice_Student.java
More file actions
52 lines (52 loc) · 1.65 KB
/
Copy pathpractice_Student.java
File metadata and controls
52 lines (52 loc) · 1.65 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
import java.util.*;
class Grade{
String name;
int rollno;
double marks;
public void displayinfo(){
System.out.println("Name:"+this.name);
System.out.println("Roll No:"+this.rollno);
}
public void calculategrade(double totalmarks){
this.marks=(this.marks/totalmarks)*100;
System.out.println("Percentage:"+this.marks);
if(this.marks>=90){
System.out.println("Grade:A+");
}
else if(this.marks>=80 && this.marks<90){
System.out.println("Grade:A");
}
else if(this.marks>=70 && this.marks<80){
System.out.println("Grade:B");
}
else if(this.marks>=60 && this.marks<70){
System.out.println("Grade:C");
}
else if(this.marks>=50.0 && this.marks<60){
System.out.println("Grade:D");
}
else{
System.out.println("Grade:Fail");
}
}
}
public class practice_Student {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
Grade g1=new Grade();
System.out.print("Enter Name:");
try {
g1.name=sc.nextLine();
System.out.print("Enter Your Rollno:");
g1.rollno=sc.nextInt();
System.out.print("Enter Your Marks:");
g1.marks=sc.nextDouble();
System.out.print("Enter Total Marks:");
double totalmarks=sc.nextDouble();
g1.displayinfo();
g1.calculategrade(totalmarks);
} catch (Exception e) {
System.out.println("Error Occurred:");
}
}
}