caught java.io.char_java - 编译错误java.io.IOExeption错误必须被捕获或声明 - 堆栈内存溢出...

这是我从未见过的新错误,我将非常感谢您的帮助

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; 必须被抓住或宣布被抛出

先感谢您

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值