-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path31_ObjectPassing.java
More file actions
85 lines (80 loc) · 1.84 KB
/
31_ObjectPassing.java
File metadata and controls
85 lines (80 loc) · 1.84 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
/*
* Program on object passing
*/
package javaprograms;
/**
*
* @author Geeky Keshav
*/
class ObjectPassing
{
String name;
int rollno;
float perc;
String grade;
ObjectPassing(String s, int r, float p)
{
name=s;
rollno=r;
perc=p;
}
void disp()
{
System.out.println("Student name: "+name);
System.out.println("Student Roll no.: "+rollno);
System.out.println("Student's Percentage: "+perc);
System.out.println("Student's Grade: "+grade);
System.out.println("***********************");
}
}
class std_marks
{
public static void main(String [] args)
{
ObjectPassing obj1=new ObjectPassing("Geeky",100,85);
ObjectPassing obj2=new ObjectPassing("Keshav",101,70);
ObjectPassing obj3=new ObjectPassing("Geeky Keshav",102,50);
std_grade(obj1);
System.out.println("**********************");
obj1.disp();
std_grade(obj2);
obj2.disp();
std_grade(obj3);
obj3.disp();
}
static void std_grade(ObjectPassing g)
{
if(g.perc>=80)
{
g.grade="A";
}
else if(g.perc>60 && g.perc<75)
{
g.grade="B";
}
else if(g.perc>=60 && g.perc<50)
{
g.grade="C";
}
else
g.grade="F";
}
}
/******OUTPUT****
**********************
Student name: Geeky
Student Roll no.: 100
Student's Percentage: 85.0
Student's Grade: A
***********************
Student name: Keshav
Student Roll no.: 101
Student's Percentage: 70.0
Student's Grade: B
***********************
Student name: Geeky Keshav
Student Roll no.: 102
Student's Percentage: 50.0
Student's Grade: F
***********************
*/