Site hosted by Angelfire.com: Build your free website today!
Blog Tools
Edit your Blog
Build a Blog
View Profile
« November 2008 »
S M T W T F S
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
Entries by Topic
All topics  «
You are not logged in. Log in
my fan site
Sunday, 11 January 2004
payroll
public class Payroll
{
public static void main (String[] args)
{
Staff personnel = new Staff();
personnel.payday();
}
}








import java.text.DecimalFormat;

public class Staff
{
StaffMember[] staffList;

public Staff()
{
staffList = new StaffMember[6];
Executive laf = new Executive ("Lala Laferty", "123 Main Line", "555-0469",
"123-45-6789", 2000.00);
staffList[0] = laf;
staffList[1] = new Employee ("Robin Droppings", "456 Off Line", "555-0101",
"987-65-4321", 1200.00);
staffList[2] = new Employee ("Allen Wrench", "789 Off Rocker", "555-0000",
"010-20-3040", 1000.00);
Hourly bob = new Hourly ("Bobbi Soks", "678 Fifth Ave.", "555-0690",
"958-47-3625", 15.00);
staffList[3] = bob;
staffList[4] = new Volunteer ("Stu Meet", "987 Suds Blvd.", "555-8374");
staffList[5] = new Volunteer ("Justin Thyme", "321 Duds Lane", "555-7282");

laf.awardBonus();
bob.addHours(46);
}
public void payday()
{
System.out.println("Project 10\n\n");
System.out.println("Lafs Computer Geeks Weekly Payroll Report \n");

for(int count = 0; count < staffList.length; count++)
{
if(count < 4)
{
System.out.print(staffList[count]);
double amount = staffList[count].pay();

System.out.println(amount);
System.out.println("-----------------------------------");
}
else
{
System.out.print(staffList[count]);
}
}
}
}








public abstract class StaffMember
{
protected String name;
protected String address;
protected String phone;
protected int hoursworked;

public StaffMember (String one, String two, String three)
{
name = one;
address = two;
phone = three;
}
public String toString()
{
String whole = "Name: " + name + "\n" +"Address: " + address + "\n" + "Phone: " +
phone + "\n" + "Thanks for your time!" + "\n" + "-----------------------------------" + "\n";
return whole;
}
public abstract double pay();
}







public class Employee extends StaffMember implements pay
{
protected String socialSecurityNumber;
protected double payRate;

String fname;
String place;
String pnum;

public Employee(String name, String address, String phone, String security, double pay)
{
super(name, address, phone);
socialSecurityNumber = security;
payRate = pay;
}
public String toString()
{
fname = name;
place = address;
pnum = phone;
String whole = "Name: " + fname + "\n" +"Address: " + place + "\n" +
"Phone: " + pnum + "\n" + "Social Security Number: " + socialSecurityNumber + "\n" +
"Paid: $";
return whole;
}
public double pay()
{
return payRate;
}
}






public class Executive extends Employee implements pay
{
double bonus;
double salary;

public Executive(String name, String address, String phone, String security, double pay)
{
super(name, address, phone, security, pay);
bonus = 0.00;
salary = pay;
}
public void awardBonus()
{
bonus = 5000.00;
}
public double pay()
{
return salary + bonus;
}
}





public class Hourly extends Employee implements pay
{
double payment;
double wage;

public Hourly(String name, String address, String phone, String security, double pay)
{
super(name, address, phone, security, pay);
hoursworked = 0;
wage = pay;
}
public void addHours(int moreHours)
{
hoursworked += moreHours;
}
public double pay()
{
if(hoursworked > 40)
{
return ((40 * wage) + ((hoursworked - 40) * wage * 1.5));
}
else
{
payment = hoursworked * wage;
return payment;
}
}
public String toString()
{
fname = name;
place = address;
pnum = phone;

String whole = "Name: " + fname + "\n" +"Address: " + place + "\n" +
"Phone: " + pnum + "\n" + "Social Security Number: " + socialSecurityNumber + "\n" +
"Current Hours: " + hoursworked + "\n" + "Paid: $";
return whole;
}
}






public class Volunteer extends StaffMember implements pay
{
public Volunteer(String name, String address, String phone)
{
super(name, address, phone);
}
public double pay()
{
return 0.00;
}
}






public interface pay
{
double pay();
}

Posted by linux/isgreat1 at 6:04 PM EST
Post Comment | Permalink | Share This Post

public class Payroll
{
public static void main (String[] args)
{
Staff personnel = new Staff();
personnel.payday();
}
}








import java.text.DecimalFormat;

public class Staff
{
StaffMember[] staffList;

public Staff()
{
staffList = new StaffMember[6];
staffList[0] = new Executive ("Lala Laferty", "123 Main Line", "555-0469",
"123-45-6789", 2000.00);
staffList[1] = new Employee ("Robin Droppings", "456 Off Line", "555-0101",
"987-65-4321", 1200.00);
staffList[2] = new Employee ("Allen Wrench", "789 Off Rocker", "555-0000",
"010-20-3040", 1000.00);
staffList[3] = new Hourly ("Bobbi Soks", "678 Fifth Ave.", "555-0690",
"958-47-3625", 15.00);
staffList[4] = new Volunteer ("Stu Meet", "987 Suds Blvd.", "555-8374");
staffList[5] = new Volunteer ("Justin Thyme", "321 Duds Lane", "555-7282");

}
public void payday()
{
System.out.println("Project 10\n\n");
System.out.println("Lafs Computer Geeks Weekly Payroll Report \n");

for(int count = 0; count < staffList.length; count++)
{
if(count < 4)
{
System.out.print(staffList[count]);
double amount = staffList[count].pay();

System.out.println(amount);
System.out.println("-----------------------------------");
}
else
{
System.out.print(staffList[count]);
}
}
}
}








public abstract class StaffMember
{
protected String name;
protected String address;
protected String phone;
protected int hoursworked;

public StaffMember (String one, String two, String three)
{
name = one;
address = two;
phone = three;
}
public String toString()
{
String whole = "Name: " + name + "\n" +"Address: " + address + "\n" + "Phone: " +
phone + "\n" + "Thanks for your time!" + "\n" + "-----------------------------------" + "\n";
return whole;
}
public abstract double pay();
}







public class Employee extends StaffMember implements pay
{
protected String socialSecurityNumber;
protected double payRate;

String fname;
String place;
String pnum;

public Employee(String name, String address, String phone, String security, double pay)
{
super(name, address, phone);
socialSecurityNumber = security;
payRate = pay;
}
public String toString()
{
fname = name;
place = address;
pnum = phone;
String whole = "Name: " + fname + "\n" +"Address: " + place + "\n" +
"Phone: " + pnum + "\n" + "Social Security Number: " + socialSecurityNumber + "\n" +
"Paid: $";
return whole;
}
public double pay()
{
return payRate;
}
}






public class Executive extends Employee implements pay
{
double bonus;
double salary;

public Executive(String name, String address, String phone, String security, double pay)
{
super(name, address, phone, security, pay);
bonus = 0.00;
salary = pay;
}
public void awardBonus()
{
bonus = 5000.00;
}
public double pay()
{
this.awardBonus();
return salary + bonus;
}
}






public class Hourly extends Employee implements pay
{
double payment;
double wage;

public Hourly(String name, String address, String phone, String security, double pay)
{
super(name, address, phone, security, pay);
hoursworked = 0;
wage = pay;
}
public void addHours(int moreHours)
{
hoursworked += moreHours;
}
public double pay()
{
if(hoursworked > 40)
{
return ((40 * wage) + ((hoursworked - 40) * wage * 1.5));
}
else
{
payment = hoursworked * wage;
return payment;
}
}
public String toString()
{
fname = name;
place = address;
pnum = phone;
this.addHours(46);
String whole = "Name: " + fname + "\n" +"Address: " + place + "\n" +
"Phone: " + pnum + "\n" + "Social Security Number: " + socialSecurityNumber + "\n" +
"Current Hours: " + hoursworked + "\n" + "Paid: $";
return whole;
}
}






public class Volunteer extends StaffMember implements pay
{
public Volunteer(String name, String address, String phone)
{
super(name, address, phone);
}
public double pay()
{
return 0.00;
}
}






public interface pay
{
double pay();
}

Posted by linux/isgreat1 at 2:39 PM EST
Post Comment | Permalink | Share This Post

Newer | Latest | Older