public class AgeException extends Exception {
public AgeException(){
super();
}
public AgeException(String msg){
super(msg);
}
}
public class InsuranceCheck {
public static void main(String args[]){
int money;
try {
money=judge(1998);
System.out.println(money);
} catch (AgeException e) {
e.printStackTrace();
}
}
public static int judge(int age) throws AgeException{
int ages;
ages=2010-age;
if(ages<16){
throw new AgeException("未满16周岁,不需要交保险!");
}
ages=ages-16;
if(ages<4&&ages>=0){
return 2000;
}
else
return 1000;
}
}