import java.io.*; public class Employee { int eid; String ename;
void tostring()
{
System.out.print("Enter Your ID:");
eid=Integer.parseInt(in.readLine());
System.out.print("Enter Your Name:");
ename=in.readLine();
}
} public class Manager extends Employee { float commission;
void ComputeSalary()
{
tostring();
System.out.print("Enter Your Commission:Rs.");
commission=Float.parseFloat(in.readLine());
System.out.print("Enter Your Salary:");
Salary=Float.parseFloat(in.readLine());
float tsalary=commission+salary;
System.out.print("Your Total Salary:Rs."+tsalary);
}
} public class SalesPerson extends Manager { int sales;
void ComputeSalary()
{
toString();
System.out.print("Enter Your Commission:Rs.");
commission=Float.parseFloat(in.readLine());
System.out.print("Enter Your Sales:");
sales=Integer.parseInt(in.readLine());
float tsalary=commission+sales;
System.out.print("Your Total Salary:Rs."+tsalary);
}
} public class Wage extends salesPerson { int hr,rate;
void ComputeSalary()
{
tostring();
System.out.print("Enter Your Commission:Rs.");
commission=Float.parseFloat(in.readLine());
System.out.print("Enter Your Working Hours:");
hr=Integer.parseInt(in.readLine());
System.out.print("Enter Your Salary Rate/per Hour:Rs.");
rate=Integer.parseInt(in.readLine());
float tsalary=commission+(hr*rate);
System.out.print("Your Total Salary:Rs."+tsalary);
}
}
public class iheritannce { public static void mai(String args[])throws IOException { DataInputStream in=new DataInputStream(System.in); Employee A=new Employee(); Manager B=new Manager(); SalesPerson C=new SalesPerson(); Wage D=new Wage(); A.ComputeSalary(); B.ComputeSalary(); C.ComputeSalary(); D.ComputeSalary(); } }
hey,,,,,,plz anyone help me..
import java.io.*;
class Employee {
int eid; String ename;
DataInputStream in=new DataInputStream(System.in);
float salary;
void tostring()throws Exception
{
System.out.print("Enter Your ID:");
eid=Integer.parseInt(in.readLine());
System.out.print("Enter Your Name:");
ename=in.readLine();
}
void ComputeSalary()throws Exception
{
toString();
}
}
class Manager extends Employee {
float commission;
void ComputeSalary()throws Exception
{
tostring();
System.out.print("Enter Your Commission:Rs.");
commission=Float.parseFloat(in.readLine());
System.out.print("Enter Your Salary:");
salary=Float.parseFloat(in.readLine());
float tsalary=commission+salary;
System.out.print("Your Total Salary:Rs."+tsalary);
}
} class SalesPerson extends Manager { int sales;
void ComputeSalary()throws Exception
{
toString();
System.out.print("Enter Your Commission:Rs.");
commission=Float.parseFloat(in.readLine());
System.out.print("Enter Your Sales:");
sales=Integer.parseInt(in.readLine());
float tsalary=commission+sales;
System.out.print("Your Total Salary:Rs."+tsalary);
}
}
class Wage extends SalesPerson { int hr,rate;
void ComputeSalary()throws Exception
{
tostring();
System.out.print("Enter Your Commission:Rs.");
commission=Float.parseFloat(in.readLine());
System.out.print("Enter Your Working Hours:");
hr=Integer.parseInt(in.readLine());
System.out.print("Enter Your Salary Rate/per Hour:Rs.");
rate=Integer.parseInt(in.readLine());
float tsalary=commission+(hr*rate);
System.out.print("Your Total Salary:Rs."+tsalary);
}
}
public class Inheritance {
public static void main(String args[])throws Exception {
Employee A=new Employee();
Manager B=new Manager();
SalesPerson C=new SalesPerson();
Wage D=new Wage();
A.ComputeSalary();
B.ComputeSalary();
C.ComputeSalary();
D.ComputeSalary();
}
}