文章目录
- 一、switch
- 二、switch 和 调用参数
- 总结
一、switch
代码如下(示例):
import java.util.Scanner;public class Calculator { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("输入第一个数字:"); double num1 = scanner.nextInt(); System.out.print("输入一个运算符:"); String t = scanner.next(); System.out.print("输入第二个数字:"); double num2 = scanner.nextInt(); switch (t){ case "+": System.out.println(num1+t+num2+"="+(num2+num1)); break; case "-": Syst
来源地址:https://blog.csdn.net/m0_74052176/article/details/130238267