package fffff;
/*
* 定义一个Calculator工具类,声明并且实现返回值为double类型的“加、减、乘、除”4个类方法
* (参数均为两个double类型的数字)
* ,并在main函数中演示。
*/
public class Calculator {
public static void main(String[] args) {
System.out.println(jia(1,2));
System.out.println(jian(3,2));
System.out.println(cheng(4,5));
System.out.println(chu(6,6));
}
public static double jia(double x1,double x2){
double x3=x1+x2;
return x3;
}
public static double jian(double x1,double x2){
double x3=x1-x2;
return x3;
}
public static double cheng(double x1,double x2){
double x3=x1*x2;
return x3;
}
public static double chu(double x1,double x2){
double x3=x1/x2;
return x3;
}
}
|
|