-1

All I am trying to do here is have the user inputted integer from the "displayMenu" method control the switch statement above in the main method. But I get the following error in this picture when I compile:

This is the error message I get when I compile

The error basically states that my actual and informal arguments differ in length.

Here is the relevant code:

public static void main(String[] args) {

    int userChoice = displayMenu();

    switch(userChoice) {
        case 1:
            break;
        case 2:
            break;
        case 3:
            break;
        case 4:
            break;
        case 5:
            break;
    }
}

public static int displayMenu(int userSelection) {  
    Scanner keyboard = new Scanner(System.in);

    userSelection = keyboard.nextInt();
    return userSelection;
}

What does this error mean?

SpikerJG
  • 31
  • 6

2 Answers2

0

The error tells you exactly what is wrong: you're calling displayMenu without a parameter, and it requires one, an int to be precise.

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
0

You should remove the parameter from the displayMenu method.

Use

public static int displayMenu()

instead of

public static int displayMenu(int userSelection)
Ori Lentz
  • 3,668
  • 6
  • 22
  • 28