import java.io.*;
import java.lang.*;
class Super
{
String ename,eno;
Super(String ename,String eno)
{
this.ename=ename;
this.eno=eno;
}
void calc() //Super class method
{
System.out.println("We are in calc method of Super class");
}
}// Super Class closed.
class Sub extends Super
{
double basic,ta,da,hra,ded,gross,net;
Sub(String ename,String eno,double basic,double ded)
{
super(ename,eno);//Call to Super class constructor.
this.basic=basic;
this.ded=ded;
}
void calc() // Sub class method which is overridden.
{
ta=basic * 0.1;
da=basic * 0.2;
hra=basic * 0.1;
gross=basic + ta + da + hra;
net = gross - ded;
}
void disp()
{
System.out.println("Employee Details:");
System.out.println("Name: " +ename);
System.out.println("Eno: " +eno);
System.out.println("Basic Salary: " +basic);
System.out.println("TA: " +ta);
System.out.println("DA: " +da);
System.out.println("HRA: " +hra);
System.out.println("Gross Salary: " +gross);
System.out.println("Deductions: " +ded);
System.out.println("Net Salary: " +net);
}
}// Sub Class closed
class EmpInfo15
{
public static void main(String args[])throws IOException
{
String ename,eno;
double basic,ded;
DataInputStream in=new DataInputStream(System.in);
System.out.println("Enter Employee Info:");
System.out.println("Enter Employee name:");
ename=in.readLine();
System.out.println("Enter Empno:");
eno=in.readLine();
System.out.println("Enter Basic Salary:");
basic=Double.valueOf(in.readLine());
System.out.println("Enter Deductions:");
ded=Double.valueOf(in.readLine());
Sub eOb=new Sub(ename,eno,basic,ded);
eOb.calc();
eOb.disp();
}
}
import java.lang.*;
class Super
{
String ename,eno;
Super(String ename,String eno)
{
this.ename=ename;
this.eno=eno;
}
void calc() //Super class method
{
System.out.println("We are in calc method of Super class");
}
}// Super Class closed.
class Sub extends Super
{
double basic,ta,da,hra,ded,gross,net;
Sub(String ename,String eno,double basic,double ded)
{
super(ename,eno);//Call to Super class constructor.
this.basic=basic;
this.ded=ded;
}
void calc() // Sub class method which is overridden.
{
ta=basic * 0.1;
da=basic * 0.2;
hra=basic * 0.1;
gross=basic + ta + da + hra;
net = gross - ded;
}
void disp()
{
System.out.println("Employee Details:");
System.out.println("Name: " +ename);
System.out.println("Eno: " +eno);
System.out.println("Basic Salary: " +basic);
System.out.println("TA: " +ta);
System.out.println("DA: " +da);
System.out.println("HRA: " +hra);
System.out.println("Gross Salary: " +gross);
System.out.println("Deductions: " +ded);
System.out.println("Net Salary: " +net);
}
}// Sub Class closed
class EmpInfo15
{
public static void main(String args[])throws IOException
{
String ename,eno;
double basic,ded;
DataInputStream in=new DataInputStream(System.in);
System.out.println("Enter Employee Info:");
System.out.println("Enter Employee name:");
ename=in.readLine();
System.out.println("Enter Empno:");
eno=in.readLine();
System.out.println("Enter Basic Salary:");
basic=Double.valueOf(in.readLine());
System.out.println("Enter Deductions:");
ded=Double.valueOf(in.readLine());
Sub eOb=new Sub(ename,eno,basic,ded);
eOb.calc();
eOb.disp();
}
}
No comments :
Post a Comment