diff --git "a/30 \346\234\261\344\271\276\347\216\256/20230512 java.md" "b/30 \346\234\261\344\271\276\347\216\256/20230512 java.md" new file mode 100644 index 0000000000000000000000000000000000000000..402433c12dd746525941469425d24f5b257edf78 --- /dev/null +++ "b/30 \346\234\261\344\271\276\347\216\256/20230512 java.md" @@ -0,0 +1,28 @@ +```java +import java.util.Scanner; + +public class Abnormal { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + System.out.println("请输入一个整数"); + int a = sc.nextInt(); + System.out.println("请输入另外一个整数"); + int b = sc.nextInt(); + int c = a+b; + System.out.println("请输入最小范围"); + int min = sc.nextInt(); + System.out.println("请输入最大范围"); + int max = sc.nextInt(); + if(c>=max||c<=min){ + try { + throw new Exception("超出范围"); + } catch (Exception e) { + System.out.println(e);; + } + }else{ + System.out.println("他们的和是"+c); + } + + } +} +``` \ No newline at end of file