master
陈舒静 4 years ago
parent b47c78597c
commit 1d27031aa1

@ -0,0 +1,43 @@
package cn.csj.oo3;
import java.util.Scanner;
public class test {
public static void main (String[] args) {
Scanner input = new Scanner(System.in);
double a = input.nextInt();
double b = input.nextInt();
sum(a,b);
subtraction(a,b);
mul(a,b);
division(a,b);
}
private static void sum(double a, double b) {
double resum=a+b;
System.out.println(a+"+"+b+"="+resum);
}
private static void subtraction(double a,double b) {
double resub=a-b;
System.out.println(a+"-"+b+"="+resub);
}
private static void mul(double a,double b) {
double remul=a*b;
System.out.println(a+"*"+b+"="+remul);
}
private static void division(double a,double b) {
double redivision=0;
if(b!=0) {
redivision=a/b;
}
else {
redivision=0; /*表示错误*/
}
System.out.println(a+"÷"+b+"="+redivision);
}
}
Loading…
Cancel
Save