• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

if/else if statement error  RSS feed

 
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.
 
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!
 
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:-

 
Police line, do not cross. Well, this tiny ad can go through:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!