Wednesday, February 9, 2011


future partner


Friday, December 17, 2010

Monday, December 13, 2010

salary

public class SalariedEmployee extends Employee{
private double salary;
//constructer for set variables
public SalariedEmployee(String n,double s){
super(n);
salary=s;
}
//set methods
public void setSalary(double s){
salary=s;
}
//get method
public double getSalary(){
return salary;
}
//calculate salary
public double earning(){
return salary;
}
}

Hourly

public class HourlyEmployee extends Employee{
private int noOfHours;
private double hourRate;
private double overTimeRate;
//set variable constructer
public HourlyEmployee(String n,int h,double ra,double ot){
super(n);
noOfHours=h;
hourRate=ra;
overTimeRate=ot;
}
//set methods
public void setNoOfHours(int h){
noOfHours=h;
}
public void setHourRate(double ra){
hourRate=ra;
}
public void setOverTime(double ot){
overTimeRate=ot;
}
//get methods
public int getNoOfHours(){
return noOfHours;
}
public double getHourRate(){
return hourRate;
}
public double getOverTime(){
return overTimeRate;
}
//calculate salary
public double salary(){
double sal=0;
if(getNoOfHours()<=40){
sal=getNoOfHours()*getHourRate();
}
//calculate over time
else{
sal=40*getHourRate()+(getNoOfHours()-40)*getOverTime();
}
return sal;
}
}

Employee

public class Employee{
private String name;
//set variable constructer
public Employee(String n){
name=n;
}
//set methods
public void setName(String n){
name=n;
}
//get methods
public String getName(){
return name;
}
public static void main(String[]args){
SalariedEmployee se=new SalariedEmployee("niaml",20000.00);
HourlyEmployee he=new HourlyEmployee("gamini",30,0.02,0.03);
System.out.println(se.earning());
}
}

employee test

public class EmployeeTest{
public static void main(String[]args){
Employee em=new Employee();
}
}

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Bluehost Coupons