Java版计算器(两数运算/循环接收数据/scanner用户交互)
package com.method; import java.util.Scanner; public class Demo03_Calculator { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Demo03_Calculator demo03 = new Demo03_Calculator(); while(true){ //这里Java中的while不能用0/1表示,只能用布尔值表示 char c=scanner.next().charAt(0); double m= scanner.nextDouble(); double n= scanner.nextDouble(); demo03.cal(c,m,n); } } public void cal(char c,double...i){ switch (c){ case '+': System.out.println(i[0]+i[1]); break; case '-': System.out.println(i[0]-i[1]); break; case '*': System.out.println(i[0]*i[1]); break; case '/': System.out.println(i[0]/i[1]); break; default: break; } } }