package method;/* * 四则运算计算器 * */import java.util.Scanner;public class Demo07{    public static void main(String[] args)    {        Scanner scanner = new Scanner(System.in);        int a = 0;        int num1 = 0, num2 = 0;        System.out.println("请选择运行方法");        System.out.println("1.加法\t2.减法\t3.乘法\t4.除法");        if (scanner.hasNextInt())        {            a = scanner.nextInt();        }        switch (a)        {            case 1 ->            {                System.out.println("请输入两个操作数");                if (scanner.hasNextInt())                {                    num1 = scanner.nextInt();                    num2 = scanner.nextInt();                }                System.out.println(add(num1, num2));            }            case 2 ->            {                System.out.println("请输入两个操作数");                if (scanner.hasNextInt())                {                    num1 = scanner.nextInt();                    num2 = scanner.nextInt();                }                System.out.println(sub(num1, num2));            }            case 3 ->            {                System.out.println("请输入两个操作数");                if (scanner.hasNextInt())                {                    num1 = scanner.nextInt();                    num2 = scanner.nextInt();                }                System.out.println(mpc(num1, num2));            }            case 4 ->            {                System.out.println("请输入两个操作数");                if (scanner.hasNextInt())                {                    num1 = scanner.nextInt();                    num2 = scanner.nextInt();                }                System.out.println(div(num1, num2));            }            default -> System.out.println("输入非法");        }        scanner.close();    }    //加法运算    public static int add(int num1, int num2)    {        return num1 + num2;    }    //减法运算    public static int sub(int num1, int num2)    {        return num1 - num2;    }    //乘法运算    public static int mpc(int num1, int num2)    {        return num1 * num2;    }    //除法运算    public static int div(int num1, int num2)    {        return num1 / num2;    }}