class Employee
{
private int age;
private int id;
private int salary;
private String name;
private String position;
public Employee(String name, int id, int salary, int age, String position)
{
this.name = name;
this.id = id;
this.salary = salary;
this.age = age;
this.position = position;
}
public int getFedTax()
{
//please note that rounding errors do occur here
return (int)((salary-800)*0.17);
}
public int getSsTax(int rate)
{
//I'm unsure if you meant division or modulus in your question
//this one assumes division:
return (int)((rate/100)/salary);
//if you meant modulus, comment the above and uncomment this:
//return (int)(rate%salary);
//once again, rounding errors will occur
}
public int getHealthFee(int rate)
{
//same code as getSsTax, really, so we could cheat and do:
//return getSsTax(rate)
//...but that would probably annoy whoever will be marking this. So:
return (int)((rate/100)/salary);
//once again, rounding errors will occur
}
public int getInsurance()
{
//once again, the same rounding errors
if (salary<40)
return (int)(salary*0.03);
if (salary<50)
return (int)(salary*0.04);
if (salary<60)
return (int)(salary*0.05);
else
return (int)(salary*0.06);
}
public double getNetPay()
{
//as the other methods return integers, I dont see the point of returning
//a double...but hey, the assignment asks you to - *shrugs*
return salary-getFedTax()-getSsTa
}
}
class sham850sAssignment
{
public static void main (String [] args)
{
Employee Fred = new Employee("Freddy", 1, 1000000, 22, "Garbage sanitisor");
Employee Sarah = new Employee("Sarah", 1, 500000, 46, "<<Insert humorous profession name>>");
System.out.println("Fred's
System.out.println("Fred's
System.out.println("Fred's
System.out.println("Fred's
System.out.println("Fred's
System.out.println("------
System.out.println("Sarah'
System.out.println("Sarah'
System.out.println("Sarah'
System.out.println("Sarah'
System.out.println("Sarah'
}
}
Main Topics
Browse All Topics





by: anokun7Posted on 2007-05-13 at 19:50:52ID: 19082744
We would certainly help you - but please share with us what you have come up so far. If you have not yet started writing the class, then I urge you to start asap with whatever understanding you have... anything! And we will gladly guide you in the best way you could finish it...
Hope that helps.