The details of the class to be implemented are as follows: 1. A TaxableWorker co
ID: 3530488 • Letter: T
Question
The details of the class to be implemented are as follows: 1. A TaxableWorker contains a name, an hourly pay rate (ie. 12.50/hr), and a federal tax rate (ie. 0.25). An explicit value constructor must be provided to set all three values. There must be mutator methods to change the values of the pay rate and the tax rate. There must be ONE workerInfo method that returns a string containing the name, hourly pay rate, and federal tax rate. There must be a grossPay method that takes the number of hours worked as a parameter and calculates the gross pay (hours * payRate) and returns that as a double. There must be a taxWithheld method that takes a gross pay amount as a parameter and calculates the tax withheld (grossPay * taxRate) and returns that as a double.Explanation / Answer
This is exact what u wanted.please rate 5.thnx
-------------------------------------------------------------------
package demo1;
public class TaxableWorker {
String name;
double rate;
double tax;
public TaxableWorker(String name, double rate, double tax) {
super();
this.name = name;
this.rate = rate;
this.tax = tax;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getRate() {
return rate;
}
public void setRate(double rate) {
this.rate = rate;
}
public double getTax() {
return tax;
}
public void setTax(double tax) {
this.tax = tax;
}
public String workerInfo ()
{
String s=new String("name:"+this.name+",rate :"+this.rate+", tax :"+this.rate);
return s;
}
public double grossPay(int hours)
{
return hours*this.rate;
}
public double taxWithheld(double grossPay)
{
return grossPay*this.tax/100;
}
public static void main(String[] args)
{
TaxableWorker t=new TaxableWorker("amit",100,5);
String info=t.workerInfo();
System.out.println(info);
double gross=t.grossPay(10);
System.out.println(gross);
double tax=t.taxWithheld(gross);
System.out.println(tax);
}
}