这是我从未见过的新错误,我将非常感谢您的帮助
import java.util.Scanner;
public class InClass_Module_5 {
public static void main(String[] args) {
//char choice;
String vehicle1, vehicle2, vehicle3, vehicle4, anStr;
vehicle1 = "Mercedes-Benz C350 Sport Sedan";
vehicle2 = "Volkswagen Touareg";
vehicle3 = "Nissan Murano";
vehicle4 = "Ford F-150";
anStr = " is a perfect vehicle for you!";
System.out.println("Enter the letter corresponding to the vehicle you would like to own:");
Scanner in = new Scanner(System.in);
char choice;
System.out.print("\nEnter the letter corresponding to the vehicle you would like to own: ");
choice = (char)System.in.read();
if(choice >= 'A' && choice <= 'D')
//choice += 32;
if(choice >= 'a' && choice <= 'd')
//choice -= 32;
System.out.println("A. " + vehicle1);
System.out.println("B. " + vehicle2);
System.out.println("C. " + vehicle3);
System.out.println("D. " + vehicle4);
System.out.println("You chose letter: " + choice);
if (choice == 'A') {
System.out.println("The " + vehicle1 + anStr);
} else if (choice == 'B'){
System.out.println("The " + vehicle2 + anStr);
} else if (choice == 'C') {
System.out.println("The " + vehicle3 + anStr);
} else if (choice == 'D') {
System.out.println("The " + vehicle4 + anStr);
} else {
System.out.println("You made an in-valid selection and will not be driving anything today!");
}
}
}
错误 :
找到1个错误:文件:/ Users / gcaruso / Documents / CISS 110 / Module 3 / Module 4 / InClass_Module_5.java [行:31]错误:/ Users / gcaruso / Documents / CISS 110 / Module 3 / Module 4 / InClass_Module_5。 java:31:未报告的异常java.io.IOException; 必须被抓住或宣布被抛出
先感谢您