hourly wages

am i using the "final" constant value correctly?

i dont think i am... let me know please?

also one line of code is not compiling....

in the second part, testWork.

Work(double hours, double wage, double fedTax, double stateTax){

i am not sure why...

import chn.util.*;

import apcslib.*;

class Work{

privatedouble myHours;

privatedouble myWage;

finaldouble myFedTax;

finaldouble myStateTax;

Work(){

myWage = 1;

myHours = 1;

myStateTax = .15;

myFedTax = .04;

}

Work(double hours,double wage,double fedTax,double stateTax){

myHours = hours;

myWage = wage;

myFedTax = fedTax;

myStateTax = stateTax;

}

publicdouble calcGrossPay(){

return Math.round(myWage*myHours);

}

publicdouble calcFedTax(){

return Math.round(myFedTax*calcGrossPay());

}

publicdouble calcStateTax(){

return Math.round(myStateTax*calcGrossPay());

}

publicdouble calcNetPay(){

return Math.round(calcGrossPay() - calcStateTax() - calcFedTax());

}

}

import chn.util.*;

import apcslib.*;

publicclass testWork{

publicstaticvoid main(String[ ]args){

double wage, hours;

int choice = 2;

ConsoleIO keyboard =new ConsoleIO();

do{

System.out.println("Want to know how much you made this month?");

System.out.println("What's your hourly wage?");

wage = keyboard.readDouble();

System.out.println("How many hours did you work?");

hours = keyboard.readDouble();

Work jobA =new Work(wage, hours);

System.out.println("Gross Pay =" +"$" + jobA.calcGrossPay());

System.out.println("Federal Tax = " +"$" + jobA.calcFedTax());

System.out.println("State Tax =" +"$" + jobA.calcStateTax());

System.out.println("Net Pay =" +"$" + jobA.calcNetPay());

System.out.println("Have another job? Type 1 for Yes2 for No");

choice = keyboard.readInt();

}while (choice ==1);

System.out.println("See ya! Hope you get a raise!");

}

}

[4331 byte] By [cvockrodta] at [2007-11-26 20:02:20]
# 1
im sorry that was the wrong line that wouldnt compile...its really:Work jobA = new Work(wage, hours);
cvockrodta at 2007-7-9 23:01:26 > top of Java-index,Java Essentials,New To Java...
# 2

Work jobA = new Work(wage, hours);

You're telling the compiler to look for the constructor in the Work class that takes 2 variables.

Look at your Work class now. You have 2 constructors(which is fine) but one of them takes no parameters, and the other takes 4.

So now you just have to create another constructor that takes 2 parameters or modify one of the existing constructors.

lethalwirea at 2007-7-9 23:01:26 > top of Java-index,Java Essentials,New To Java...