Hi,

What's the best way to round doubles as in currency? I also have this error that says: internal error, cannot instantiate paycheck(java.lang.string, double, double) at paycheck to (). If you need to see the codes, I can post them. Any help at all would be greatly appreciated!

Thanks!

Yes if you post the code it will be helpfull.

public String printGrossPay()
    {
        return "The gross pay for this paycheck period is: $" +grossPay;
    }

    public String printNetPay()
    {
         return "The net pay for this paycheck period is: $" +netPay;
    }

    public String printAmountDeducted()
    {
         return "The total amount of taxes deducted for this paycheck period is: $" +amountDeducted;
    }

paycheck p1 = new paycheck(nameInput, hourInput, wageInput);

Helpful?

What jars your project requeres?

What jars your project requeres?

what are jars? I'm still in an introductory class

The code you posted is not enough can you please gave more information about your paycheck class and the entire error?

public paycheck(String name, int hours, double wage)
    {
        federalTax=.10;
        socialSecurityTax=.0865;
        hours1=0;
        wages=0;
    }

    public double grossPay()
    {
        grossPay=hours1*wages;

        return grossPay;
    }

    public double amountDeducted()
    {
        amountDeducted=grossPay*(federalTax+socialSecurityTax);

        return amountDeducted;
    }
    public double netPay()
    {
        netPay=grossPay-amountDeducted;

        return netPay;
    }

The paycheck is a function not a class; and the functions could not be instanciated. that mean we should not write some think like:

paycheck p1 = new paycheck(nameInput, hourInput, wageInpu

this is wrong. the word "new" is used to create an instance of class and MUST not be used for functions

Hope it helps.

The paycheck is a function not a class; and the functions could not be instanciated. that mean we should not write some think like:

paycheck p1 = new paycheck(nameInput, hourInput, wageInpu

this is wrong. the word "new" is used to create an instance of class and MUST not be used for functions

Hope it helps.

Except that according to the code the OP posted, "paycheck" is a constructor, so in fact, the word 'new' would be used.

Except that according to the code the OP posted, "paycheck" is a constructor, so in fact, the word 'new' would be used.

You know what's funny? paycheck wasn't capitalized! Ah, I love when silly mistakes like that cause me to go crazy!

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.