package TbT;
import java.util.*;
public class doublecircle {
    public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    System.out.println("请输入圆的半径");
    double r,s;
    double PI=3.14;
    r=sc.nextInt();
    try {
        s=PI*r*r;
        System.out.println(s);
    }
    catch(Exception e) {
        e.printStackTrace();
        
    }
    }

}
package TbT;
import java.util.*;
public class idcard {
    String id;
    static void avg(String id)throws IllegalArgumentException
{
        if(id.length()!=18) {
            throw new IllegalArgumentException("长度不符合");
        }
        else {
            System.out.println("长度合法");
        }
        
        
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        idcard p=new idcard();
        try {
            System.out.println("请输入身份证号:");
            p.id=sc.next();
            idcard.avg(p.id);
        }
        catch(IllegalArgumentException e) {
            System.out.println(e);
        }
        
    }

}

第五次实训异常处理第五次实训异常处理

相关文章:

  • 2021-10-23
  • 2021-09-01
  • 2021-11-29
  • 2021-09-13
  • 2021-08-25
  • 2021-05-21
猜你喜欢
  • 2021-04-23
  • 2022-12-23
  • 2021-05-17
  • 2021-09-29
  • 2022-12-23
  • 2021-11-18
  • 2021-06-18
相关资源
相似解决方案