Results 1 to 5 of 5
  1. #1
    beginnerprog is offline Member
    Join Date
    Mar 2013
    Posts
    22
    Rep Power
    0

    Default selecting options in java

    Hi im new to the java language.

    import javax.swing.JOptionPane;

    public class TravelAgentSystem {

    public static void main(String[] args) {
    // Local variable declared
    int selectValue;

    // Main Menu is displayed

    System.out.println("| Flight Travel Systems |");
    System.out.println("|--------------------------|");
    System.out.println("| Options: |");
    System.out.println("| 1. Time |");
    System.out.println("| 2. Price |");
    System.out.println("| 3. Hotels |");
    System.out.println("| 4. End |");
    System.out.println("============================") ;

    selectValue();

    }
    public static void selectValue()
    {

    int choice = -1;
    while(choice < 0)
    {
    String input = JOptionPane.showInputDialog("Please select an option: ");
    }

    }
    }

    I want to make it so when i select an option such as 1, it will take me to a new option where i can display more infomation.
    Anyone know how i can go about doing this?
    Last edited by beginnerprog; 03-01-2013 at 07:04 PM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

  3. #3
    beginnerprog is offline Member
    Join Date
    Mar 2013
    Posts
    22
    Rep Power
    0

    Default Re: selecting options in java

    import javax.swing.JOptionPane;

    public class TravelAgentSystem {

    public static void main(String[] args) {
    // Local variable declared
    int selectValue;

    // Main Menu is displayed

    System.out.println("| Flight Travel Systems |");
    System.out.println("|--------------------------|");
    System.out.println("| Options: |");
    System.out.println("| 1. Time |");
    System.out.println("| 2. Price |");
    System.out.println("| 3. Hotels |");
    System.out.println("| 4. End |");
    System.out.println("============================") ;

    selectValue();

    }
    public static void selectValue()
    {

    int choice = -1;
    while(choice < 0)
    {
    String input = JOptionPane.showInputDialog("Please select an option: ");
    choice +=1;
    if (input.equals("1")){
    System.out.println("fdsfds");
    }
    else if (input.equals("2")){
    System.out.println("ggfdgd " );
    }
    else if (input.equals("3")){
    System.out.println("hgfdhgf " );
    }
    else if (input.equals("4")){
    System.out.println("nhgdhd " );
    }
    else {
    JOptionPane.showMessageDialog(null, "User error,please select an option");
    choice-=1;
    }

    }
    }
    }

    cheers
    now im trying to make it so when i enter 1 i get a list of flights and choose a destination in which i can work out the estimated time

    how would i go about doing this any ideas?
    do i create a new class?
    Last edited by beginnerprog; 03-01-2013 at 10:43 PM.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default Re: selecting options in java

    You could make a start by going through all the three links I already posted, and applying the knowledge you gain.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Aries. is offline Member
    Join Date
    Jan 2013
    Posts
    22
    Rep Power
    0

    Default Re: selecting options in java

    Quote Originally Posted by beginnerprog View Post
    import javax.swing.JOptionPane;

    public class TravelAgentSystem {

    public static void main(String[] args) {
    // Local variable declared
    int selectValue;

    // Main Menu is displayed

    System.out.println("| Flight Travel Systems |");
    System.out.println("|--------------------------|");
    System.out.println("| Options: |");
    System.out.println("| 1. Time |");
    System.out.println("| 2. Price |");
    System.out.println("| 3. Hotels |");
    System.out.println("| 4. End |");
    System.out.println("============================") ;

    selectValue();

    }
    public static void selectValue()
    {

    int choice = -1;
    while(choice < 0)
    {
    String input = JOptionPane.showInputDialog("Please select an option: ");
    choice +=1;
    if (input.equals("1")){
    System.out.println("fdsfds");
    }
    else if (input.equals("2")){
    System.out.println("ggfdgd " );
    }
    else if (input.equals("3")){
    System.out.println("hgfdhgf " );
    }
    else if (input.equals("4")){
    System.out.println("nhgdhd " );
    }
    else {
    JOptionPane.showMessageDialog(null, "User error,please select an option");
    choice-=1;
    }

    }
    }
    }

    cheers
    now im trying to make it so when i enter 1 i get a list of flights and choose a destination in which i can work out the estimated time

    how would i go about doing this any ideas?
    do i create a new class?


    Use switch statements instead, instead of using S.O.P. just use the JOptionPane.showMessageDialog . Then state your problem here properly and what output do you expected. I'm not an expert Im just studying this language then.

    Thanks.

Similar Threads

  1. Replies: 1
    Last Post: 03-28-2012, 12:43 PM
  2. Replies: 7
    Last Post: 08-12-2011, 05:54 PM
  3. Set Java Control Panel options via Command Prompt
    By pguih in forum Advanced Java
    Replies: 0
    Last Post: 05-09-2011, 04:24 PM
  4. Selecting every other array
    By Rivy2112 in forum New To Java
    Replies: 10
    Last Post: 10-11-2010, 10:39 PM
  5. problem with Java Vm options
    By DonnieDarko in forum Advanced Java
    Replies: 1
    Last Post: 11-21-2007, 03:22 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
  •