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

  • Home
  • SEARCH
  • 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 8754575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:39:13+00:00 2026-06-13T13:39:13+00:00

I am trying to create a menu in the console and have the user

  • 0

I am trying to create a menu in the console and have the user select an option, for some reason when I run the application it goes straight to the else, bypassing options a-d.

import java.util.Scanner;

public class UserChoice {


 public static void main(String[] args) 
{
    boolean status = true;
    while (status == true)
    {
    System.out.println("");
    System.out.println("MENU");
    System.out.println("");
    System.out.println("A : String Functions");
    System.out.println("B : Simple Arithmetic Functions");
    System.out.println("C : Temperature Conversion");
    System.out.println("D : Sequences");
    System.out.println("E : Exit Application");
    System.out.println("");
    System.out.println("Please make a selection.");
            Scanner keyboard = new Scanner(System.in);
    String choice =null;
    choice = keyboard.nextLine();





    if (choice == "a" || choice == "A")
    {
        StringFunctions();
    }

    else if (choice == "b" || choice == "B")
    {
        ArithmeticFunctions();
    }

    else if (choice == "c" || choice == "C")
    {
        TemperatureConversion();
    }

    else if (choice == "d" || choice == "D")
    {
        Sequences();
    }

    else if (choice == "e" || choice == "E")
    {
        System.exit(0);
    }
    else 
    {
        System.out.println("You have entered an invalid selection, please choose again.");

    }
    }

}
  • 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-13T13:39:14+00:00Added an answer on June 13, 2026 at 1:39 pm

    All String/Object comparisons should use equals() method instead of == (except String literals)

    if (choice.equals("a") || choice .equals( "A")){....}
    

    Apply same change to other else/if blocks also.

    == compares reference equality. equals() method checks for content equality.

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

Sidebar

Related Questions

I am trying to create a menu. And, for some reason I get org.hibernate.exception.GenericJDBCException:
I am trying to create a menu bar for my application. I have created
I'm trying to create some Menu Item with Image & Label, using barry's class
I have been trying to create a menu panel with jQuery that can be
Im trying to create a menu item so when a user clicks on the
I want to create a dynamic select input (dropdown menu) from JSON. I have
I am trying to create a menu where when you click anywhere else on
I am trying to create dropdown menu for Wordpress theme and having some silly
I'm trying to create a menu and draw it with GDI. I have a
I am trying to create a menu(no dropdown) using jquery. Please check some of

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.