package com.jiang.method; import java.util.Scanner; public class Counter { public static void main(String[] args) { jisuanqi(); } public static void jisuanqi(){ Scanner scanner = new Scanner(System.in); while (true){ System.out.println("请输入第一个数"); double a = scanner.nextDouble(); System.out.println("请输入运算符"); String type = scanner.next(); System.out.println("请输入第二个数"); double b = scanner.nextDouble(); scanner.close(); switch (type){ case "+": System.out.println("结果为:"+add(a,b)); continue; case "-": System.out.println("结果为:"+less(a,b)); continue; case "*": System.out.println("结果为:"+Multiply(a,b)); continue; case "/": System.out.println("结果为:"+except(a,b)); continue; default: System.out.println("无效运算符"); } } } //加法 public static double add(double now,double jia){ return now+jia; }public static double less(double now,double jian){ return now-jian; }public static double Multiply(double now,double chen){ return now*chen; }public static double except(double now,double chu){ return now/chu; } }