-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAss13.java
More file actions
181 lines (144 loc) · 4.24 KB
/
Ass13.java
File metadata and controls
181 lines (144 loc) · 4.24 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
package person13;
import java.util.Date;
class Person
{
int age;
double weight,height;
Date dateOfBirth;
String address;
void setData(int age,double weight,double height,Date dateOfBirth,String address) //set values
{
this.age=age;
this.weight=weight;
this.height=height;
this.dateOfBirth=dateOfBirth;
this.address=address;
}
void show()
{
System.out.println(" Age " +age+ " yr Weight "+ weight + " Kg Height " + height + " inch Date of Birth "+dateOfBirth+" Address "+address);
}
}
class Employee extends Person
{
long salary;
Date dateOfJoining;
int experience;
void setData(long salary,Date dateOfJoining,int experience,int age,double weight,double height,Date dateOfBirth,String address)
{
super.setData(age,weight,height,dateOfBirth,address);
this.salary=salary;
this.dateOfJoining=dateOfJoining;
this.experience=experience;
}
void show()
{
super.show();
System.out.println(" Salary "+salary+" Date of Joining "+dateOfJoining+" Experience "+experience);
}
}
class Student extends Person
{
int roll,noOfSub=5;
String listOfSubjects[];
int marks[];
void setData(int roll,int age,double weight,double height,Date dateOfBirth,String address)
{
super.setData(age,weight,height,dateOfBirth,address);
this.roll=roll;
noOfSub=5;
listOfSubjects=new String[noOfSub];
// listOfSubjects=takeSubject(listOfSubjects);
listOfSubjects[0]="Java";
listOfSubjects[1]="DSA";
listOfSubjects[2]="Computer";
listOfSubjects[3]="C";
listOfSubjects[4]="Newtwork";
marks=new int[noOfSub];
marks[0]=95;
marks[1]=90;
marks[2]=85;
marks[3]=80;
marks[4]=75;
}
String calculateGrade(int n)
{
// String A,B;
if(n>50)
{
return "A";
}
else
{
return "B";
}
}
void show()
{
super.show();
System.out.println(" Roll "+roll);
System.out.println("List of Subjects "+listOfSubjects[0]+" Marks "+marks[0]);
System.out.println("List of Subjects "+listOfSubjects[1]+" Marks "+marks[1]);
System.out.println("List of Subjects "+listOfSubjects[2]+" Marks "+marks[2]);
System.out.println("List of Subjects "+listOfSubjects[3]+" Marks "+marks[3]);
System.out.println("List of Subjects "+listOfSubjects[4]+" Marks "+marks[4]);
}
}
class Technician extends Employee
{
void setData(long salary,Date dateOfJoining,int experience,int age,double weight,double height,Date dateOfBirth,String address)
{
super.setData(salary,dateOfJoining,experience,age,weight,height,dateOfBirth,address);
}
void show()
{
super.show();
}
}
class Professor extends Employee
{
String course;
String listOfAdvisee[];
void setData(String course,long salary,Date dateOfJoining,int experience,int age,double weight,double height,Date dateOfBirth,String address)
{
super.setData(salary,dateOfJoining,experience,age,weight,height,dateOfBirth,address);
this.course=course;
listOfAdvisee=new String[3];
listOfAdvisee[0]="QWE";
listOfAdvisee[1]="RTY";
listOfAdvisee[2]="UIO";
}
void show()
{
super.show();
System.out.println(" Course "+course);
System.out.println(" List of Advisee "+ listOfAdvisee[0]);
System.out.println(" "+ listOfAdvisee[1]);
System.out.println(" " + listOfAdvisee[2]);
}
}
class Ass13
{
public static void main(String args[])
{
Person p=new Person();
Date d1=new Date(1996,07,10);
p.setData(23,60.0,6.0,d1,"Kolkata");
p.show();
Employee e=new Employee();
Date d2=new Date(2004,05,14);
e.setData(45000L,d2,2,23,50.0,5.0,d1,"Jalpaiguri");
e.show();
Student st=new Student();
st.setData(1,23,60.0,6.0,d1,"Kolkata");
st.show();
System.out.println(" Calculate Grade "+st.calculateGrade(100));
System.out.println(" Calculate Grade "+st.calculateGrade(25));
Technician t=new Technician();
t.setData(70000L,d2,3,23,55.0,5.5,d2,"Siliguri");
t.show();
Professor pr=new Professor();
pr.setData("Webdevlopment",35000L,d2,2,22,65.0,5.0,d1,"Sikim");
pr.show();
}
}