You never defined your input variable in the body of the menu method. Try adding Scanner input = new Scanner(System.in) within the menu method. Simply defining the variable in main does not give menu access to it. If you want to avoid creating a Scanner instance multiple times, you could do something like
import java.util.Scanner;
public class MathMenu {
private static Scanner input = new Scanner(System.in);
...
}
Then you could use input from all of your methods.
EDIT: I just noticed something similar for
m and
n: you have to define them within the method in which they are being used, or make them
static fields. If it was up to me I'd do it like this:
import java.util.Scanner;
public class MathMenu {
private static Scanner input = new Scanner(System.in);
private static int n = 15;
private static int m = 8;
// ...
// your other methods unchanged
// ...
public static void main(String[] args) {
menu(args); // or just "menu()" if you remove the arguments from the menu method declaration.
}
}