Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: How can I create an option menu with while and switch statements?

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How can I create an option menu with while and switch statements?

    0 down vote favorite


    I'm trying to create a menu where you have four options:

    You can register a bird you have seen in a textfile.
    You can write the type of a bird you have seen.
    You can write the place where you have seen the bird.
    Close the program

    This is what I have done so far:

    import easyIO.*;

    class Menu {

    public static void main(String[] args) {

    int counter = 0;
    while (counter != 4) {
    counter = meny();

    switch (counter) {
    case 1:
    ReigsterBird(1);
    break;
    case 2:
    WriteBirdType(2);
    break;
    case 3:
    WritePlace(3);
    break;
    case 4:
    break;

    default:
    System.out.println("Give a number between 1 and 4");

    }
    }
    }

    But I keep getting these errors, and also i'm not sure how I can solve this. Is there something i'm missing?

    Menu.java:9: error: cannot find symbol
    counter = meny();
    ^
    symbol: method meny()
    location: class Menu
    loop.java:13: error: cannot find symbol
    ReigsterBird(1);
    ^
    symbol: method ReigsterBird(int)
    location: class Menu
    Menu.java:16: error: cannot find symbol
    WriteBirdType(2);
    ^
    symbol: method WriteBirdType(int)
    location: class Menu
    loop.java:19: error: cannot find symbol
    WritePlace(3);
    ^
    symbol: method WritePlace(int)
    location: class Menu
    4 errors

    I would appreciate if someone could help out on this so I could create a menu where you have four options you can choose from.


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: How can I create an option menu with while and switch statements?

    counter = meny();
    Your code calls a method called meny. Where is it?
    Improving the world one idiot at a time!

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How can I create an option menu with while and switch statements?

    I figured out that I need some help with creating that method from the statements i've posted. Do you know any hints or examples for how i can create method from those statements?

  4. #4
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: How can I create an option menu with while and switch statements?

    You have managed to create a main method. Why do you have problems creating other methods?
    Improving the world one idiot at a time!

  5. #5
    Member
    Join Date
    May 2013
    Posts
    106
    My Mood
    Amused
    Thanks
    16
    Thanked 9 Times in 9 Posts

    Default Re: How can I create an option menu with while and switch statements?

    You have managed to create a main method. Why do you have problems creating other methods?
    Not necessarily. Eclipse generates the main method automatically. A lot of programming courses teach some of the basic stuff first and get to functions a little later. Often instructors will teach new students to write out the basic skeleton of the main method, because it is required, and tell them to put their code in there without explaining that it is a method.

    Dabbish, if you have a textbook, it should have a section on creating functions (aka methods, sorry if I confused you by using the terms interchangeably). If not, this link should help.

Similar Threads

  1. Im very new to java And switch statements
    By RevChe in forum Loops & Control Statements
    Replies: 9
    Last Post: March 17th, 2013, 10:14 AM
  2. Switch problem. How do I return to my menu?
    By jonny007 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 28th, 2012, 12:54 PM
  3. IF and SWITCH Statements: How and When to Use Them
    By snowguy13 in forum Java Programming Tutorials
    Replies: 2
    Last Post: January 11th, 2012, 10:46 AM
  4. Help with switch statements
    By suxen in forum Loops & Control Statements
    Replies: 4
    Last Post: February 15th, 2011, 04:55 AM
  5. need help with JButton and switch statements
    By jjoubert in forum AWT / Java Swing
    Replies: 5
    Last Post: October 28th, 2009, 09:13 AM

Tags for this Thread