JAVA从键盘输入2个数字,输出两个数字的“+、-、*、/、%”的运算表达式及运算结果

问题描述:

JAVA从键盘输入2个数字,输出两个数字的“+、-、*、/、%”的运算表达式及运算结果

import java.util.Scanner;
public class Test01 {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
float num1,num2;
System.out.print("请输入两个数!\n第一个数:");
num1=scan.nextFloat();
System.out.print("第二个数:");
num2=scan.nextFloat();
System.out.println(num1+"+"+num2+"="+(num1+num2));
System.out.println(num1+"-"+num2+"="+(num1-num2));
System.out.println(num1+"*"+num2+"="+(num1*num2));
System.out.println(num1+"/"+num2+"="+(num1/num2));
System.out.println(num1+"%"+num2+"="+(num1%num2));
}
}