package object;import java.util.InputMismatchException;import java.util.Scanner;public class trunk { static int rentNum; public static void main(String[] args) { // TODO Auto-generated method stub Scanner input=new Scanner(System.in); int rentmoney=input.nextInt(); while(true) { try { System.out.println("Please input RentNum:"); //Scanner input2=new Scanner(System.in); //rentNum=input2.nextInt();为什么把下面一行替换成这一行就可以用了 rentNum=input.nextInt(); break; }catch( InputMismatchException e) { System.out.println("你应该输入整数:"); e.printStackTrace(); } } System.out.println("租金:"+rentmoney+"数量:"+rentNum); }}
添加回答
举报
0/150
提交
取消