-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethodOverride.java
More file actions
51 lines (48 loc) · 1.21 KB
/
Copy pathMethodOverride.java
File metadata and controls
51 lines (48 loc) · 1.21 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
package OOPJava;
import java.util.Scanner;
class Employee1 {
double salary,DA,HRA,salary1;
Employee1(double salary,double DA,double HRA) {
this.salary=salary;
this.DA=DA;
this.HRA=HRA;
}
void display () {
System.out.println("EMPLOYEE");
System.out.println("----------");
}
void calcsalary () {
salary1=salary+salary*(DA/100)+salary*(HRA/100);
System.out.println("Gross Salary="+salary1);
}
}
class Engineer extends Employee1 {
Engineer(double salary,double DA,double HRA) {
super (salary,DA,HRA);
}
void display () {
super.display ();
super.calcsalary ();
System.out.println("ENGINEER");
System.out.println("---------");
}
void calacsalary () {
System.out.println("Gross Salary of the Engineer="+salary1*2);
}
}
public class MethodOverride {
public static void main (String args[]) {
double salary,DA,HRA;
Scanner sc=new Scanner (System.in);
System.out.println("Enter the basic salary of the Employee:");
salary=sc.nextDouble ();
System.out.println("Enter DA% of Employee:");
DA=sc.nextDouble ();
System.out.println("Enter HRA% of Employee:");
HRA=sc.nextDouble ();
Engineer engg=new Engineer ( salary,DA,HRA);
engg.display ();
engg.calacsalary ();
sc.close ();
}
}