• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Beginner problem

 
Greenhorn
Posts: 20
Android Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I got a problem set from my teacher this morning. The task is to figure out the little mistakes in the code he also said there is more coming. And I know its super easy for some of you but not for me. My main concern here is else if statement.

I want to know/ learn about else if specifically any ideas? Books, chapter, Tutorials anything...
 
Greenhorn
Posts: 14
Mac Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How much do you need?
There are a lot of tutorials about else if.
Try these-
This the old is gold
The new gold
and if you are looking for texts go for this and http://www.c4learn.com/java/java-if-statement/
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ryan Gabriel wrote:I want to know/ learn about else if specifically any ideas? Books, chapter, Tutorials anything...


Well, here's the link to the tutorials, which I got by Googling "java tutorials if statement". Just look for anything that starts with docs.oracle.com/javase/tutorial...

However "else if" is just a bit of syntactic sugar that allows you to writerather than:The two constructs are basically identical; the "else if" just saves you a pile of indentation.

Winston
 
Marshal
Posts: 76872
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What errors have you found? Do you mean compiler errors, poor design of the class, or what? Poor style? Tell us how many errors you have found.

There is no such thing as an else if stattement. What you have is an if embedded in the second part of an if‑else. If your first condition is not fulfilled, control goes to the else, and is immediately confronted with another test and another if. Start with the Java™ Tutorials. You cannot see it the way you write else if on one line. Everybody uses the one line technique, but this shows the actual structure of the if‑elses in that methodYou will probably never see a block of if‑else‑elses written like that again. But note the levels of indentation (which you don't usually write) and that shows how the ifs are embedded inelses.

If you have 90+ it is an A+ otherwise if you have 80+ it is an A otherwise if you have 70+ is it a B+ otherwise...
 
Campbell Ritchie
Marshal
Posts: 76872
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That c4learn tutorial is not at all good, I am afraid.
 
Greenhorn
Posts: 5
Oracle Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not going to list the specific errors, but I found 9 mistakes in the code. As Winston already posted, the Oracle Java tutorials is a good place to start.
 
"Don't believe every tiny ad you see on the internet. But this one is rock solid." - George Washington
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic