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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:00:17+00:00 2026-05-23T12:00:17+00:00

This is dealing with java to start. My goal is to take in a

  • 0

This is dealing with java to start.
My goal is to take in a Vin number and store it into a string. Make sure it has no more than 9 characters. Also the Vin Number is only supposed to contain numbers and letters a-z or A-Z. If the user inputs an invalid Vin number it should loop back around and prompt for a new Vin Number. My problem is telling whether the string contains anything other than integers or letters. I’ve seen the Utility.IsAlphaNumeric method but I can’t figure out how to implement it or whether it’s even a java method. NetBeans gives me errors whenever I try to use it.

private static String checkVin() {
    Scanner input = new Scanner(System.in);
    String vinNumber = "";
    do {
        System.out.println("Please enter the vin number of the car");
        vinNumber = input.next();
        if (vinNumber.length() > 9) {
            System.out.println("invalid input for Vin number");
        }
        for (int i = 0; i < vinNumber.length(); i++) {
            char currentCharacter = vinNumber.charAt(i);

            if ((currentCharacter < '0' || currentCharacter > '9')
                    || !( currentCharacter < 'a' || currentCharacter > 'z')
                    || !(currentCharacter > 'A' || currentCharacter > 'Z'));
            System.out.println("invalid input for Vin Number");
            break;
        }
        return vinNumber;

    } while (true);
}
  • 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-23T12:00:17+00:00Added an answer on May 23, 2026 at 12:00 pm

    Utility is not the name of a class from the core libraries.

    You can replace the entire check loop with

    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    
    private static final Pattern VALID_VIN_NUMBER = Pattern.compile(
        "[0-9a-zA-Z]{1,9}");
    
    public static boolean isVin(String s) {
      return VALID_VIN_NUMBER.matcher(s).matches();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm an experienced C/C++ programmer getting into Java and looking for a good IDE
I've been dealing with this for years but it's so nit-picky that I never
I'm trying to find the most efficient way of dealing with this but I
We all know it is needed. But WHY is it needed in Java alone,
I do mean the ??? in the title because I'm not exactly sure. Let
I have been using DOM for a long time and as such DOM parsing
I have been considering a range of options to move away form using scriptlets
Our system communicates with several web services providers. They are all invoked from a
Ok, so I am working on a homework assignment, and I am using SWING
Hey Im working on a folder tree and need to be able to limit

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.