輸入一個星期數(shù),如何編寫不管輸入的是大寫漢字還是阿拉伯?dāng)?shù)字都可以識別的程序
?System.out.println("請輸入一個星期數(shù)"); ???Scanner?in=new?Scanner(System?in); ???int?x=in.nextInt(); ???if(xxxxx)
?System.out.println("請輸入一個星期數(shù)"); ???Scanner?in=new?Scanner(System?in); ???int?x=in.nextInt(); ???if(xxxxx)
2016-09-04
舉報
2016-09-04
好像沒有一個數(shù)據(jù)類型可以支持匹配數(shù)字類型的和漢子類型的。
2016-09-06
do{
????System.out.println("輸入錯誤請重新輸入");
????????System.out.println("請輸入一個星期數(shù)");
???????? Scanner in=new Scanner(System.in);
?? ????int x=in.nextInt();
??
}while(x<1 || x>7)
//只要輸入數(shù)字小于1或者大于7就循環(huán)輸入
2016-09-04
?System.out.println("請輸入一個星期數(shù)");
???????? Scanner in=new Scanner(System.in);
?? int x=in.nextInt();
??? if((x<1||x>7)){
???? System.out.println("輸入錯誤請重新輸入");