class WorkerDetail
{
int c,s;
String n;
float h;
void SetSalary(int x, String y, int z)
{
c=x;
n=y;
s=x;
}
void ShowDetail()
{
System.out.println("Code : "+ c);
System.out.println("Name : "+n);
System.out.println("Salary : "+s);
}
void getHra()
{
h=(float)s*60/100;
System.out.println("HRA : "+h);
}
}
class officerDetail extends WorkerDetail
{
float d,g;
void getda()
{
d=(float)s*98/100;
System.out.println("DA : "+d);
}
void getGross()
{
g=s+h+d;
System.out.println("Gross : "+g);
}
};
class ExInheritance
{
public static void main(String args[])
{
WorkerDetail wD = new WorkerDetail();
officerDetail oD = new officerDetail();
wD.SetSalary(121,"Aman",13000);
oD.SetSalary(111,"Amrik",30000);
System.out.println("Detail of Worker is :");
wD.ShowDetail();
wD.getHra();
System.out.println("Detail of Officer is :");
oD.ShowDetail();
oD.getHra();
oD.getda();
oD.getGross();
}
};