| Member with 9 posts. THREAD STARTER | | Join Date: Jul 2012 Experience: Beginner | |
Solved: "illegal start of expression" -- I've checked -- what am I missing? System is PC Win 7 SP1 64-bit for what that's worth in this situation. I'm a rank beginner in Java, pretty new to programming in general. The following code (within a larger program) generates 4 "illegal start of expression" errors (lines marked).
I've matched my brackets for the entire program, there are no methods within methods. Notice that all four errors are on "if" statements with logical operators && and ||. The code lines with a simple > don't throw errors. Am I using the operators wrong?
Thank you! if (gender == "f")
{ if (age >= 25 && <= 29) //error 1
System.out.println("The female renter is " + age + " years old. The rate class is: Rate 1 - $50.00 per day or $255.00 " +
"per week.");
else if (age >=30 && <= 62) //error 2
System.out.println("The female renter is " + age + " years old. The rate class is: Best rate - 40.00 per day or " +
"$200.00 " + "per week.");
else
if (age > 62)
System.out.println("The female renter is " + age + " years old. The rate class is: Rate 3 - " + (40 + ((age-62) * 2)) +
" per day or " + (200 + ((age-62) * 5)) + " per week.");
else
System.out.println("Sorry, the renter is not 25 years of age or older.");
}
else
{ if (age >= 25 && <= 32) //error 3
System.out.println("The male renter is " + age + " years old. The rate class is: Rate 2 - $57.00 per day or $285.00 " +
"per week.");
else if (age >= 33 || <= 65) //error 4
System.out.println("The male renter is " + age + " years old. The rate class is: Best rate - 40.00 per day or " +
"$200.00 per week.");
else
if (age > 65)
System.out.println("The male renter is " + age + " years old. The rate class is: Rate 3 - " + (40 + ((age-65) * 2)) +
" per day or " + (200 + ((age-65) * 5)) + " per week.");
else
System.out.println("Sorry, the renter is not 25 years of age or older.");
} |