This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

if/else if statement error

 
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
PHP AngularJS Java
  • 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:-

 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic