标签:system else span imp 计算 sys equals equal 类对象
1 import java.util.Scanner; 2 /* 3 * @author zhang 4 * time 2019.01.12 5 */ 6 public class JiSuanQi { 7 double num1; 8 double num2; 9 double he; 10 int i =1; 11 Scanner input = new Scanner(System.in); 12 13 14 public void result() { 15 do{ 16 System.out.println("请输入第一个数字:"); 17 num1 = input.nextDouble(); 18 System.out.println("请输入运算符:"); 19 String fuHao = input.next(); 20 System.out.println("请输入第二个数字:"); 21 num2 = input.nextDouble(); 22 if(fuHao.equals("+")) { 23 System.out.println(num1+"+"+num2+"="+(num1+num2)); 24 }else if(fuHao.equals("-")) { 25 System.out.println(num1+"-"+num2+"="+(num1-num2)); 26 }else if(fuHao.equals("*")) { 27 System.out.println(num1+"*"+num2+"="+(num1*num2)); 28 }else if(fuHao.equals("/")) { 29 System.out.println(num1+"/"+num2+"="+(num1/num2)); 30 }else { 31 System.out.println("您输入的运算有误!请重新输入"); 32 continue; 33 } 34 System.out.println("是否继续计算?1为继续,0为退出"); 35 i = input.nextInt(); 36 }while(i == 1); 37 System.out.println("谢谢使用!"); 38 } 39 }
1 public class TestJiSuanQi { 2 public static void main(String[] args) { 3 JiSuanQi jieGuo = new JiSuanQi(); 4 jieGuo.result(); 5 } 6 }
标签:system else span imp 计算 sys equals equal 类对象
原文地址:https://www.cnblogs.com/Zhangchuanfeng1/p/10260244.html