package com.baidu.www; import java.util.Scanner; public class JiShuanQi { public static void main(String[] args) { //实现用户输入 Scanner scanner = new Scanner(System.in); while (true){ double num1= scanner.nextDouble(); String next = scanner.next(); double num2= scanner.nextDouble(); double num3=num1;//难点 double num4=num2; double result =0; if(next.equals("+")){ result = add(num1,num2); } if(next.equals("-")){ result = jian(num1,num2); } if(next.equals("*")){ result = cheng(num1,num2); } if(next.equals("/")){ result = chu(num1,num2); } if(next.equals("!")){ break; } System.out.println(result); } } public static double add(double a, double b){ return a+b; } public static double jian(double a,double b) { return a-b; } public static double cheng(double a,double b) { return a*b; } public static double chu(double a,double b) { return a/b; } }
标签:num1,num2,实现,double,next,计数器,result,public,加减乘除 From: https://www.cnblogs.com/zsjdbk/p/16929681.html