Also, in the default constructor, how do I set the char to a default value, similiar to a null string?
Here's the class:
And here's the driver:
Originally posted by Ernest Friedman-Hill:
A big hint: put a line like
in the private grossPay() method, and then run your program again.
By doing that I realized I'm not calling the grossPay() and netPay() methods. In the project requirements it says the methods need to be private (this may be a typo, I'll ask).
I changed the methods to public and had the driver call them and it spits out computed numbers. But if they do have to be private is there any way to call those methods from the driver?
I also changed the grossPay() and netPay() so they return a double, instead of them being void methods.
[ March 07, 2005: Message edited by: Greg Roberts ]
I don't know if you have solved your problem or not, but I made one change and had your program running. The only thing I did was move the call to the grossPay() and netPay() methods inside the getGrossPay() and getNetPay() methods, respectively.
I think you logic issue is naming the the two methods as "calculateGrossPay" and "calculateNetPay".
Everything else seems to work.
Best of luck,
Since all instance fields are initialized by the JVM (chars get '\u0000'), I'd remove the initialization of it from the constructor.
Originally posted by Greg Roberts:
What would you normally use in a default constructor for a char variable?
Just to test, I added the following line to one of my classes:and it compiled fine using JDK 1.4.2_05. I have no idea why javac isn't liking it on your end.