pls help me with this problem......its for my exam for finals...pls help me....

here are the instructions:

Create a Class of the ff:
(focus on payroll)

1. EmployeePay (parent)
define: attribute: salary(net), gross, rate, no of hours worked, tax=20%
constructor: (2)
method: setters/getters, reset()-set number of hours work to 0

formula: gross=rate*no. of hrs worked
salary= gross-(gross*tax)

2. BetterEmployeePay (child)
define: attribute: normal, overtime rate
constructor: (2)
method: setters/getters, override the method for salary

formula: overtime pay=(no. of hours worked - normal) * overtime rate
gross= (rate* no of hours worked)+ overtime pay

3. create a tester class for the child class with 1 object displaying the rate, no. of hours worked, excess hours (optional), gross, overtime pay(optional) and salary


Please help me with this.....ty..

Recommended Answers

All 5 Replies

Since this is your exam it means that you attended a whole semester of your java course. Surely you would know how to create classes with attributes.

Well the instructions are pretty clear:

Create a Class
.....
EmployeePay (parent)
define: attribute: salary(net), gross, rate, no of hours worked, tax=20%
constructor: (2)

You would advise you to follow them

So that's why the quality of newly graduated programmers is so poor.
They're now handing out exam assignments that would be considered too simplistic for a 1st week homework assignment at the beginning of a course.

for my own practice
i leave the calculation part to you
try using constructors (methods with same name as class)

class Employeepay
{
private int salary_net;
private int gross;
private int noofhrs;
public void setters(int sal,int gr,int noofhr)
{
salary_net=sal;
gross=gr;
noofhrs=noofhr;
}
}
class betterEmployeepay extends Employeepay
{
private int myattributes;
public void setters_1()
{
}
public void getters_1()
{
}
}

class myapp
{
public static void main(String args[])
{
betterEmployeepay obj=new betterEmployeepay();
//obj.declaredmethods();
}
}

i am sure our seniors will help me better my post

ty so much to you guys....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.