有人可以向我解释为什么当输入 !sdesf 作为邮政编码时它说 !sdesf 在东海岸。不应该是 !sdesf 是一个无效的邮政编码。这是我的代码
String zipCode;
Scanner input = new Scanner(System.in);
System.out.print("Enter 4-digit zip code: ");
zipCode = input.nextLine();
if (zipCode.charAt(0) <= '3')
System.out.println(zipCode + " is on the East Coast.");
if (zipCode.charAt(0) >= '4')
if (zipCode.charAt(0) <= '6')
System.out.println(zipCode + " is in the Central Plains area.");
if (zipCode.charAt(0) == '7')
System.out.println(zipCode + " is in the South.");
if (zipCode.charAt(0) >= '8')
if (zipCode.charAt(0) <= '9')
System.out.println(zipCode + " is in the West.");
else
System.out.println(zipCode + " is an invalid ZIP Code.");