-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethodOverriding
More file actions
55 lines (55 loc) · 1.12 KB
/
Copy pathMethodOverriding
File metadata and controls
55 lines (55 loc) · 1.12 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
package javalab;
import java.util.Scanner;
class Employeee
{
double salary,DA,HRA,salary1;
Employeee(double salary,double DA,double HRA)
{
this.salary=salary;
this.DA=DA;
this.HRA=HRA;
}
void display()
{
System.out.println("Employee....");
}
void calcSalary()
{
salary1=salary+salary*(DA/100)+salary*(HRA/100);
System.out.println("Gross salary of empolyee="+salary1);
}
}
class Engineer extends Employeee
{
Engineer(double salary,double DA,double HRA)
{
super(salary,DA,HRA);
}
void display()
{
super.display();
super.calcSalary();
System.out.println("Engineer...");
}
void calcSalary()
{
System.out.println("Gross salary of Engineer="+salary1*2);
}
}
public class MethodOverriding
{
public static void main(String[] args)
{
double salary,DA,HRA;
Scanner s=new Scanner(System.in);
System.out.println("Enter the basic salary of employee=");
salary=s.nextDouble();
System.out.println("Enter the DA% of the employee=");
DA=s.nextDouble();
System.out.println("Enter the HRA% of the employee=");
HRA=s.nextDouble();
Engineer e=new Engineer(salary,DA,HRA);
e.display();
e.calcSalary();
}
}