Items Needed Validate Java Vehicle Vin Exactly 10 Characters Combination Letters Digits Ve Q37261092

Items needed tovalidate in JAVA:

–Vehicle VIN: exactly10 characters (a combination of letters and digits)

–Vehicle Make: allalphabetic

–Vehicle Model:letters and digits

I tried to validatevin put its not working…

public static booleanvalidateVIN(String input)
{

if(input.length() == 10)
{
for(int i = 0; i < input.length(); i++)
{
if(!Character.isDigit(input.charAt(i)))
return false;
}//end for
for(int i = 0; i < input.length(); i++)
{
if(!Character.isAlphabetic(input.charAt(i)))
return false;
}//end for
return true;
}
return false;
}//end validateVIN

Sample VIN could be any combination of numbers andletters
ex. ABC123DEF4


Answer


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.