小编min*_*i19的帖子

Integer.parseInt 抛出的 NumberFormatException

嘿,我在学校上编程课,但老师没有很好地解释,所以我们必须在网上寻找我所做的信息,但我无法在我的代码中找到错误,你能帮我吗?

char end='s';     
do{
    System.out.println("Tipo de boleto");
    char boleto = (char) System.in.read();
    switch (boleto){
        case 'a':
          System.out.println("El boleto cuesta $120.00");
          System.out.println("Otro boleto (s/n)?");
          end = (char) Integer.parseInt(entrada.readLine());
          continue;
    case 'n':
          System.out.println("El boleto cuesta $75.00");
          System.out.println("Otro boleto (s/n)?");
          end = (char) Integer.parseInt(entrada.readLine());
          continue;
    case 'i':
          System.out.println("El boleto cuesta $60.00");
          System.out.println("Otro boleto (s/n)?");
          end = (char) Integer.parseInt(entrada.readLine());;
          continue;
    default:
          System.out.println("Error" );
          break;
    }
}
  while (end == 'n');
Run Code Online (Sandbox Code Playgroud)

例外

    run: Tipo de boleto a El boleto cuesta $120.00 Otro boleto (s/n)? 

Exception …
Run Code Online (Sandbox Code Playgroud)

java numberformatexception

-1
推荐指数
1
解决办法
7647
查看次数

标签 统计

java ×1

numberformatexception ×1