-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudentThis.java
59 lines (50 loc) · 1.03 KB
/
StudentThis.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
class StudentThis
{
int i,j,k; //instance variables
String name;
public StudentThis() {} //default constructor
public StudentThis(String name, int i, int j, int k)
{
this.name = name; //local variables
this.i = i;
this.j = j;
this.k = k;
}
public void doPercentage()
{
System.out.println("Name of Student: "+name );
int p = (i+j+k)/3;
System.out.println("Percentage: "+p);
if(p >= 90)
{
System.out.println("Grade A\n");
}
else if(p >= 80)
{
System.out.println("Grade B\n");
}
else if(p >= 70)
{
System.out.println("Grade C\n");
}
else if(p >= 60)
{
System.out.println("Grade D\n");
}
else if(p >= 40)
{
System.out.println("Grade E\n");
}
else
{
System.out.println("Grade F\n");
}
}
public static void main(String[] args)
{
StudentThis a = new StudentThis();
a.doPercentage();
StudentThis a1 = new StudentThis("James",40,50,60);
a1.doPercentage();
}
}