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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:44:48+00:00 2026-05-15T09:44:48+00:00

import java.util.Scanner; public class Main extends Hashmap{ public static void main(String[] args) { Hashmap

  • 0
import java.util.Scanner;

public class Main extends Hashmap{

    public static void main(String[] args) {
        Hashmap hm = new Hashmap();
        int x=0;
        Scanner input = new Scanner(System.in);
        do{
            System.out.print("Enter any integer value between 1 to 12: ");
            x = input.nextInt();
        }while(x<=0 || x>12);
        Scanner sc = new Scanner(System.in);
        //int number;


       do {
           while (!sc.hasNextInt())
           {
            System.out.println("That's not a number!");
            sc.next();
           }
            x = sc.nextInt();
           }while(x>=0);

        String month = hm.getEntry(x);
        System.out.println(month);




}
    }

here I need to restrict user from entering an alphabet.But its not working.
pls help…

  • 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-05-15T09:44:49+00:00Added an answer on May 15, 2026 at 9:44 am
    public static void main(String[] args) {
        HashMap<Integer, String> hm = new HashMap<Integer, String>();
        /**
         * Populate hashmap.. Your logic goes here
         */
        Scanner sc = new Scanner(System.in);
        int x;
        System.out.println("Enter a number between 1 and 12");
        do {
            while (!sc.hasNextInt()) {
                System.out.println("That's not a number! Enter a number between 1 and 12");
                sc.next();
            }
            x = sc.nextInt();
            String month = hm.get(x);
            System.out.println("The corresponding month is " + month);
        } while (x >= 0);
    
    }
    

    I think this is what you are trying to achieve..

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

Sidebar

Ask A Question

Stats

  • Questions 539k
  • Answers 539k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer try this (adding parentheses since It.IsAny<TValue> is a method): mockServiceBus.Setup(x… May 17, 2026 at 2:24 am
  • Editorial Team
    Editorial Team added an answer Turns out it was my bug, WinInet doesn't actually attempt… May 17, 2026 at 2:24 am
  • Editorial Team
    Editorial Team added an answer That message is usually an indication that some of your… May 17, 2026 at 2:24 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc
I'm trying to calculate the average of a student's marks: import java.util.Scanner; public class
package myProg; import java.util.Scanner; public class oving4a { /** *Øving 4a. Aleksander Pettersen */
So, I'm getting stuck with this piece of code: import java.util.InputMismatchException; import java.util.Scanner; public
This is my Java 1.5 code (complete example): import org.junit.Test; import static org.junit.Assert.*; import
FYI This is homework. I have to build a Java Chat server. I have
I'm trying to build my first fractal (Pythagoras Tree): alt text http://img13.imageshack.us/img13/926/lab6e.jpg in Java
Hey everyone, I'm working on a hex dump utility made in Java. I'm having
Hello I am trying to implement a Priority Queue in Java from scratch with
I have written program for drawing pythagoras tree fractal. Can anybody see any way

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.