Hey guys. I am getting a fair amount of errors when trying to create this menu. I am not sure whether or not I am going about it correctly.

Without further adieu:

package assignment.pkg2;

import java.util.Scanner;

public class Assignment2 {

    public static final int MAX_NUM = 10;
    
    public static void main(String[] args) {
        
        ElementSet set = new ElementSet();
        
        Scanner keyboard = new Scanner(System.in);
        
        int menuChoice;
        
        Subscriber subList[] = new Subscriber [MAX_NUM];
        
        for(int i = 0; i < MAX_NUM ;i++)
        {
            subList[i] = new Subscriber("", "", 0);
        }
        
        static int getNumber(String message)
        {
            Scanner keyboard = new Scanner(System.in);

            return keyboard.nextInt();
        }
        static int getMenuChoice()
        {
            String message = "Here are your Choices: \n"
            + "Enter 1 to add a Subscriber \n"
            + "Enter 2 to add an Application \n"
            + "Enter 3 to flag a Subscriber \n"
            + "Enter 4 to flag an Application \n"
            + "Enter 5 to unflag a Subscriber \n"
            + "Enter 6 to unflag and Application \n"
            + "Enter 7 to display all Subscribers \n"
            + "Enter 8 to display all Applications \n"
            + "Enter 9 to Quit \n";
            
            return getNumber(message);
        }
        
        menuChoice = getMenuChoice();

        while(menuChoice != 9)
        {
            switch(menuChoice)
            {
        
            case 1:
                //add subscriber to Element Set array
            break;
            
            case 2:
                //add application to Element Set array
            break;
            
            case 3:
                //flag a specified subscriber
            break;
            
            case 4:
                //flag a specified application
            break;
            
            case 5:
                //unflag a specified subscriber
            break;
            
            case 6:
                //unflag a specified application
            break;
            
            case 7:
                //display all subscribers in the Element Set array
            break;
            
            case 8:
                //display all applications in the Element Set array
            break;
                
            }
            
            menuChoice = getMenuChoice();
        }
        

}

ERRORS:

Line 22: reached end of file while parsing
Line 24: Illegal start of expression
Line 46: Cannot find symbol 'class menuChoice()'
Line 48: Cannot find symbol 'class menuChoice()'
Line 50: Cannot find symbol 'variable menuChoice()'
Line 87: Cannot find symbol 'variable menuChoice()'

I don't exactly understand why this is happening. Any ideas?

Edited 5 Years Ago by Syrne: n/a

1)You are attempting to create methods inside the main() method. You need to take them outside the main(). Then you call them in main() instead.
2)Each method outside the main(), you may not need "static" keyword to make the method static. You should learn how to use "static" method in the future.
3)Any method you implement, it needs to be public, protected, or private. Normally, public is the one you would use.

Edited 5 Years Ago by Taywin: n/a

1)You are attempting to create methods inside the main() method. You need to take them outside the main(). Then you call them in main() instead.
2)Each method outside the main(), you may not need "static" keyword to make the method static. You should learn how to use "static" method in the future.
3)Any method you implement, it needs to be public, protected, or private. Normally, public is the one you would use.

Ah, that makes sense.

So used to C++, heh.

I'll fix it, but leave this open in case any more questions arise. If not, I'll mark it solved.

Thanks you!

EDIT: Solved. Thanks again.

Edited 5 Years Ago by Syrne: n/a

Ah, if you have done C++ before, Java is very easy. ;) Just need to be familiar with its syntax.

This question has already been answered. Start a new discussion instead.