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 8571149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:43:11+00:00 2026-06-11T18:43:11+00:00

I am having trouble getting my menu below to run from my driver. The

  • 0

I am having trouble getting my menu below to run from my driver. The program will execute, however it will not display my menu until I enter a number. After that it will display properly, and it reads selection properly, but will not call the methods I have listed in the case statement.

For instance, if I input a ‘1’, the menu will recognize I input a 1 and will display the menu again with “You entered 1”. instead of calling dec.getDec(), as it should according to the case statement. Any helpful hints or advice would be appreciated. This is a homework assignment, and I am not trying to get someone to write the code for me or anything. I just need to be pointed in the right direction please.

import java.io.IOException;
import java.io.*;
import java.util.Scanner;

public class Menu {
    Scanner scan = new Scanner(System.in); 
    int selection;

    public int GetSelection()
   {
       selection = scan.nextInt();
       return selection;
   }

    public void display()
    {

          System.out.println("Please choose an option from the following:"); 
          System.out.println("[1] Convert Decimal to Binary"); 
          System.out.println("[2] Convert Decimal to Hexadecimal"); 
          System.out.println("[3] Convert Binary to Decimal"); 
          System.out.println("[4] Convert Binary to Hexadecimal"); 
          System.out.println("[5] Convert Hexadecimal to Decimal"); 
          System.out.println("[6] Convert Hexadecimal to Binary"); 
          System.out.println("[0] Exit");

          System.out.println("\n");
          System.out.println("You entered: " + selection);
   }

}


----------------------------
import java.io.*;
import java.lang.*;
import java.util.Scanner;


public class Driver
{

    public static void main(String[] args)throws IOException {

            LineWriter lw = new LineWriter("csis.txt");
            int selection;

            Decimal dec = new Decimal();
            Binary bin = new Binary();
            Hexadecimal hex = new Hexadecimal();
            Menu menu = new Menu();


        do{ 
            menu.display();

            selection=menu.GetSelection();

            switch (selection){

            case '1':{ dec.getDec();
                      break;}
            case '2':{ dec.getHex();
                      break;}
            case '3':{ bin.getBin();
                      break;}
            case '4':{ bin.getHex();
                      break;}
            case '5':{ hex.getHex();
                      break;}
            case '6': { hex.getDec();
                      break;  }     
            //default: System.out.println("Error: Unrecognized Selection");
            //          break;

           }
        }while (selection !=0);
    }   
}
  • 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-11T18:43:12+00:00Added an answer on June 11, 2026 at 6:43 pm

    As this is homework, I won’t give you the whole solution, but I’ll help get you there…

    Your problem is coming from your use of Scanner, the helpful part of this page is A scanning operation may block waiting for input.

    Using that you should be able to see where the problem is, if you need more help comment on this answer and I’ll see if there’s more I can do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble getting SendMessage to activate a menu on another program. When
I'm having trouble getting my dropdown menu to still work after I empty it's
im having trouble getting a string (containing a URL) from one activity to another.
Im having trouble getting my JTable that im using to display either check boxes
I'm having trouble getting Japanese text to display properly on a website compiled using
I'm having trouble getting through the linking phase in my C++ program due to
I have the jsf code and css code below. I'm having trouble getting the
Having trouble getting this syntax right: SELECT DISTINCT id FROM metadata WHERE (meta_key =
I am having trouble getting a horizontal menu to line up correctly in IE9
Having trouble getting the oauth access token and secret exchanged from the request tokens

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.