Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8533397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:57:22+00:00 2026-06-11T09:57:22+00:00

I’m sorry if this is a weird question but I’ve just started OOP and

  • 0

I’m sorry if this is a weird question but I’ve just started OOP and ran across this problem for a simple menu driven math program that I was supposed to make. I cleared all the errors the compiler gave me but now it’s given me about 14 fresh errors most of which are described as ‘cannot find symbol.’ Here’s my code:

import java.util.Scanner;


public class MathMenu
{


//MENU METHOD
private static void menu(String args[])
{
int choice;

System.out.printf("Enter '1' to add");
System.out.printf("Enter '2' to subtract");
System.out.printf("Enter '3' to exit");

System.out.printf("\nPlease enter your choice: ");


choice=input.nextInt();

if (choice==1)
sum(n,m);

if (choice==2)
dif(n,m);

else if(choice==3)
return;

}



//SUM
private static int sum(int a, int b)
{
return n+m;
}


//DIFFERENCE 
private static int dif(int a, int b)
{
if(n<m)
return m-n;

else
return n-m;
}





public static void main(String args[])
{


int n=15;
int m=8;

Scanner input = new Scanner(System.in);

menu();

}


}

And here’s the NEW compiler output:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Shahraiz Tabassam>cd c:\java\bin

c:\java\bin>javac MathMenu.java
MathMenu.java:7: error: no suitable constructor found for Scanner()
private static Scanner input = new Scanner();
                               ^
    constructor Scanner.Scanner(ReadableByteChannel,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(ReadableByteChannel) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Path,Charset) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Path,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Path) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File,CharsetDecoder) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(File) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(InputStream,String) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(InputStream) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Readable) is not applicable
      (actual and formal argument lists differ in length)
    constructor Scanner.Scanner(Readable,Pattern) is not applicable
      (actual and formal argument lists differ in length)
MathMenu.java:64: error: method menu in class MathMenu cannot be applied to give
n types;
menu();
^
  required: String[]
  found: no arguments
  reason: actual and formal argument lists differ in length
2 errors

c:\java\bin>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:57:23+00:00Added an answer on June 11, 2026 at 9:57 am

    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.
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This could be a duplicate question, but I have no idea what search terms
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
Seemingly simple, but I cannot find anything relevant on the web. What is the
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.