关于抛出异常的一个标准小程序
package com.xuedao.pojo;
import java.util.Scanner;
public class Exception1 {
public static void main(String[] args) {
try {
scnn();
} catch (Exception e) {
System.out.println("你不符合标准,退出");
}
}
public static void scnn() throws Exception{
System.out.println("请输入你的身高、体重、年龄");
Scanner s = new Scanner(System.in);
double high = s.nextDouble();
double weight = s.nextDouble();
int age = s.nextInt();
if(high>140 && high<220 && weight>40 &&weight<100 && age>20 &&age<35) {
System.out.println("符合标准");
}else {
throw new Exception();
}
}
}