-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lab5Task5.java
64 lines (64 loc) · 1.36 KB
/
Lab5Task5.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
/*5. Create Marksheet class having three subjects as variables, methods
for calculating total marks, percentage, and grade.*/
import java.util.*;
class Marksheet
{
Scanner scanf=new Scanner(System.in);
double sub1;
double sub2;
double sub3;
double total;
double per;
public void setDetails()
{
System.out.println("Enter First subject");
sub1=scanf.nextInt();
System.out.println("Enter Sceond subject");
sub2=scanf.nextInt();
System.out.println("Enter Thrid subject");
sub3=scanf.nextInt();
System.out.println("Enter Total Marks");
total=scanf.nextInt();
}
public void calc()
{
System.out.println("Total marks: "+total);
System.out.println("Obtained Marks: "+(sub1+sub2+sub3));
sub1=sub1+sub2+sub3;
per=(sub1*100)/total;
System.out.println("Percentage: "+per);
if (per>=90)
{
System.out.println("Grade 'A'");
}
if (per>=80 && per<90)
{
System.out.println("Grade 'B'");
}
if (per>=70 && per<80)
{
System.out.println("Grade 'C'");
}
if (per>=60 && per<70)
{
System.out.println("Grade 'D'");
}
if (per>=50 && per<60)
{
System.out.println("Grade 'E'");
}
if (per<50)
{
System.out.println("Fail");
}
}
}
class Lab5Task5
{
public static void main(String[] args)
{
Marksheet mark=new Marksheet();
mark.setDetails();
mark.calc();
}
}