importjava.util.InputMismatchException;importjava.util.Scanner;publicclassFile{publicstaticvoidmain(Stringargs[]){Scannerin=newScanner(System.in);try{for(inti=0;;i++){Sys...
import java.util.InputMismatchException;
import java.util.Scanner;
public class File
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
try
{
for(int i=0;;i++)
{
System.out.println("请输入总分");
int score=in.nextInt();
System.out.println("总分是"+score);
}
}
catch(InputMismatchException e1)
{
System.out.println(" 您输入的不是数字");
/*for(int i=0;;i++)
{
System.out.println("请输入总分");
int score=in.nextInt();
System.out.println("总分是"+score);
}*/
}
}
}
/*try
{
System.out.println("请输入总分");
int score=num.nextInt();
System.out.println("请输入人数");
int name=num.nextInt();
double avg=score/name;
System.out.println(" 平均分是"+avg+"分");
}
catch(InputMismatchException e1)
{
System.out.println("您输入的不是数字");
}
catch(ArithmeticException e2)
{
System.out.println("人数不能为0");
}
catch(Exception e3)
{
System.out.println("其他异常");
}
}
}
展开