Question: public class Payroll { public static void main ( String [ ] args ) { public class Payroll { private String name; private String id;
public class Payroll
public static void mainString args
public class Payroll
private String name;
private String id;
private int hours;
private double rate;
No arg Constructor
public Payroll
name;
id;
hours;
rate;
Parameterised Constructor
public PayrollString name, String id int hours, double rate
setNamename;
setHourshours;
setIdid;
setRaterate;
setters and getters
public void setNameString name
ifname.equals
this.name name;
else
throw new IllegalArgumentExceptionName should not be empty...";
public void setIdString id
ifidlength
throw new IllegalArgumentExceptionNot a valid ID;
else if
Character.isLetteridcharAt
&& Character.isLetteridcharAt
&& Character.isDigitidcharAt
&& Character.isDigitidcharAt
&& Character.isDigitidcharAt
&& Character.isDigitidcharAt
this.id id;
else
throw new IllegalArgumentExceptionNot a valid ID;
public void setHoursint hours
ifhours && hours
this.hours hours;
else
throw new IllegalArgumentExceptionNot valid hours...";
public void setRatedouble rate
ifrate && rate
this.rate rate;
else
throw new IllegalArgumentExceptionNot valid rate...";
public String getName
return name;
public String getId
return id;
public int getHours
return hours;
public double getRate
return rate;
@Override
public String toString
return "Payroll
"name name
id id
hours hours
rate rate
;
class Payroll
public static void mainString args
try
Payroll payroll new PayrollJamesCC;
System.out.printlnpayroll;
catch IllegalArgumentException ex
System.out.printlnexgetMessage;
Iam getting these errors
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The nested type Payroll cannot hide an enclosing type
Illegal modifier for the local class Payroll; only abstract or final is permitted
Duplicate nested type Payroll
The constructor PayrollString String, int, int is undefined
at payrollclass.Payroll.mainPayrolljava:
the assignment is In this assignment, you are to create a class named Payroll.
In the class, you are to have the following data members:
name: String pts
id: String pts
hours: int pts
rate: double pts
private members pts
You are to create noarg and parameterized constructors and the appropriate settersaccessors and getters mutators pts
The class definition should also handle the following exceptions:
An employee name should not be empty, otherwise an exception should be thrown. pts
An employee id should have the form LLNNNN If that form is not received, an exception should be thrown. pts
An employee's hours should neither be negative nor greater than An exception should be thrown otherwise. pts
An employee's pay rate should neither be negative nor greater than An exception should be thrown otherwise. pts
Demonstrate this class in a program separate class or in the same class pts
The exception messages should be appropriate to the specific exception that has occurred. pts
Create a package payroll for the project. pts
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
