我的第四个程序 java实现加减乘除
import java.util.Scanner; public class Test { public static void main(String [] args) { Scanner sc = new Scanner(System.in); System.out.println("请输入算法:"); String go = sc.next(); System.out.println("请输入第一个数:"); Double a = sc.nextDouble(); System.out.println("请输入第二个数:"); Double b = sc.nextDouble(); if(go.equals("+")){ Double sum = a+b; System.out.println("他们的和为"+sum); } if(go.equals("-")){ Double sum = a-b; System.out.println("他们的差为"+sum); } if(go.equals("*")){ Double sum = a*b; System.out.println("他们的积为"+sum); } if(go.equals("/")){ Double sum = a/b; System.out.println("他们的商为"+sum); } } }