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);
}
Utilityis not the name of a class from the core libraries.You can replace the entire check loop with