Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

if/else if statement error  RSS feed

 
George McCoy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to get a student's classification based on their completed hours but I keep getting errors. I'm kind of embarrassed asking about this since I can usually do if/else if statements with no problem but lines 5 and 8 give the errors "Illegal start of expression" and I have no idea why. I've declared the hoursCompleted and classification variables so that's not the problem.
 
Trung Hieu Hoang
Greenhorn
Posts: 12
AngularJS Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The syntax is not correct. Java will not accept logical expression as

It should be


It's recommended that you first go through a Java book to get the basic exposure to Java.
 
George McCoy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I knew it was something I'd feel really dumb about afterwards. :/ That's what I get for trying to code before my first cup of coffee. Thanks!
 
Steffe Wilson
Ranch Hand
Posts: 165
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, you don't need to check that hoursCompleted are greater than a value you have previously dealt with because by that point you have entered an else state.

Hence:-

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!