Results 1 to 2 of 2
  1. #1
    Join Date
    May 2013
    Rep Power

    Default If Statements or Something Better?

    Allow me to set the scene before i ask the question. Im designing a control panel for a Java program through the BlueJ learning system. It involves fill the gas tank of an object, loading it with cargo, then entering a destination for the object to go. I want to set it where i have multiple choices for a destination each one at a different distance from the other of course. I need an easy way to code in "if destination = whatever1 then (fuel used equation), if destination = whatever2 then (fuel used equation)..." all the way through all of my options (as many as 10 total). Whats the easiest way besides nested If/Else?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: If Statements or Something Better?

    Create a Destination class and let it do the calculations:

    Java Code:
    public class Destination {
       public double fuelUsed( ... ) { ... }
    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Help with IF Statements and GUI
    By university123 in forum New To Java
    Replies: 8
    Last Post: 10-14-2010, 04:38 AM
  2. if else if statements
    By Allspark in forum New To Java
    Replies: 9
    Last Post: 09-28-2010, 06:50 PM
  3. Help with if else statements
    By np2392 in forum New To Java
    Replies: 2
    Last Post: 09-24-2010, 01:25 AM
  4. age: using if statements
    By yasmin k in forum New To Java
    Replies: 2
    Last Post: 10-04-2009, 09:50 PM
  5. Help with if-else statements
    By porchrat in forum New To Java
    Replies: 4
    Last Post: 03-23-2009, 04:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts