How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask LogicPro Your Own Question

LogicPro
LogicPro, Computer Software Engineer
Category: Programming
Satisfied Customers: 12509
Experience:  Expert in C, C++, Java, DOT NET, Python, HTML, Javascript, Design.
29751445
Type Your Programming Question Here...
LogicPro is online now
A new question is answered every 9 seconds

Payroll Program Part 3: Java. Modify the PayrollPrgram so that

This answer was rated:

Payroll Program Part 3: Java. Modify the PayrollPrgram so that it uses a class to store and retrieve the employee's name, the hourly rate, and the number of hours worked. Use a constructor to initialize the employee information, and a method within that class to calculate the weekly pay. Once stop is entered as the employee name, the application should terminate. Make sure the program maintains all the functionality required

I coded the program but i am having one problem i can not seem to figure out.
Hi,
Could you please provide Part 2?
Customer: replied 6 years ago.

http://wikisend.com/download/454524/Employee.java

 

http://wikisend.com/download/572208/PayrollProgram.java

 

Here is what i have done. I am getting one error on line 26 of the payrollprogram

it is saying that constructor Employee is not found, but i defined constructor employee in the Employee file.

Please insert following line
public Employee(){}
after line
NumberFormat nf = NumberFormat.getCurrencyInstance(); // used to format currency

in Employee.java

Ask me if you need more information.
Customer: replied 6 years ago.

 

I already have this done or do i need add second public Employee. Below is what i have.

 

public class Employee { // beging Employee class

// declare instance variabled
private String empname; // name of employee
public double payrate; // hourly payrate of employee
public double hoursworked; // weekly hours worked
private double weeklypayamount; // weekly pay sum

 

NumberFormat nf = NumberFormat.getCurrencyInstance(); // used to format currency

You are getting this error as the main program is looking for default empty constructor which is not present in Employee.java.

Add following line:
public Employee(){}
after line
NumberFormat nf = NumberFormat.getCurrencyInstance(); // used to format currency

in Employee.java


Your code will look like:

public class Employee { // beging Employee class

// declare instance variabled
private String empname; // name of employee
public double payrate; // hourly payrate of employee
public double hoursworked; // weekly hours worked
private double weeklypayamount; // weekly pay sum

 

NumberFormat nf = NumberFormat.getCurrencyInstance(); // used to format currency

public Employee(){}
// declare Employee constructor that accepts three parameters
public Employee (String empnameIn, double payrateIn, double hoursworkedIn)
{
setEmpname(empnameIn);
setPayrate(payrateIn);
setHoursworked(hoursworkedIn);
} // end Employee Constructor


Customer: replied 6 years ago.

thanks i guess my question is this why do i need to declare two Employee constructor one without parameters and one with parameters. Is there something else i should havd done to be able declare one Employee constructor. Thanks very much for the help

 

public Employee(){}
// declare Employee constructor that accepts three parameters
public Employee (String empnameIn, double payrateIn, double hoursworkedIn)
{
setEmpname(empnameIn);
setPayrate(payrateIn);
setHoursworked(hoursworkedIn);
} // end Employee Constructor

There is no way to be able to declare one Employee constructor only.
Either you declare default along with parameterized constructor or you declare none of them.
Customer: replied 6 years ago.

in Netbeans this is what it ask me to create to correct the error.. is this the same as your example... i ran the program and it seem to work. I guess i am trying to get a better understanding of the of the constructor coding. again thanks

 

NumberFormat nf = NumberFormat.getCurrencyInstance(); // used to format currency

Employee() {

}

Yes. You will need to add default constructor. This is the same.
Even if you use any IDE or java command, you will have to define default constructor if you define parameterized constructo.
LogicPro and other Programming Specialists are ready to help you