I am in the first few weeks of a beginners java course.
I have written a class that will call the class that I am having the problem with. I keep getting these "illegal start of expression" error and cant get rid of them without commenting them out.
Any assistance would be great.
TIA, Eric
Sorry I couldnt get the curly braces to line up to aid the readablity factor on this forum, any suggessions?
// Program written by: Eric R. // Date program written: 11/06/03 // Program Name: Calculate
I have cleaned the code so that you don't have extra braces. This code compiles fine. I have made getCurrencyInstance() method non-static because you are using some instance variables inside. I don't know what you are trying to do. So, just go through your logic again and compile it after every change so that you know which code is giving you problem.
// Program written by: Eric R.
// Date program written: 11/06/03
// Program Name: Calculate
import java.text.*;
publicclass Calculate {
//attibutes
double hrRate = 5.00;
double otRate;
double regPay;
long hrWork;
float otWork;
float totalHours;
double otPay;
double totalPay;
long Amin;
//constructor
public Calculate (long Amin){
this.Amin = Amin;
}
// methods
publicdouble getPay(){
return this.totalPay;
}
publicvoid setPay(long Amin){
this.totalPay = Amin;
}
publiclong getAmin(){
return this.Amin;
}
publicfinal NumberFormat getCurrencyInstance( ) {
if(hrWork < 8) {
regPay = hrWork * hrRate;
otPay = 0.00;
}
elseif(hrWork > 8) {
regPay = 8 * hrRate;
otPay = (hrWork - 8) * 1.5 * hrRate;
}
elseif(hrWork < .15) {
System.out.println("You worked 0 hours therefore you earned 0 pay ");
System.exit(0);
}
// You need to return what you intended to return here
// I have just returned null so that the code compiles fine
returnnull;
}
}
> I am in the first few weeks of a beginners java course. > > I have written a class that will call the class that I am > having the problem with. I keep getting these "illegal > start of expression" error and cant get rid of them > without commenting them out. > > Any assistance would be great. > > TIA, > Eric > > Sorry I couldnt get the curly braces to line up to aid the > readablity factor on this forum, any suggessions? > >