java编程题,急!
编写程序,提供实现各种数学计算的方法,并调用这些方法进行计算,包括如下几项:1:两个数的乘、除:2求某数的相反数、倒数、绝对值。...
编写程序,提供实现各种数学计算的方法,并调用这些方法进行计算,包括如下几项:1:两个数的乘、除:2求某数的相反数、倒数、绝对值。
展开
2个回答
展开全部
楼上正解
public class test_1_3 extends JFrame{
public static void main(String args[]){
multiple(20, 30);
dvd(20,20);
op(-20);
daoshu(2);
abs(23);
}
public static double multiple(double a, double b){
System.out.println("a*b="+a*b);
return a*b;
}
public static double dvd(double a, double b){
System.out.println("a/b="+a/b);
return a/b;
}
public static double op(double a){
System.out.println("a的相反数"+a*-1);
return a*-1;
}
public static double daoshu(double a){
System.out.println("a的倒数"+1/a);
return 1/a;
}
public static double abs(double a){
System.out.println("a的绝对值"+Math.abs(a));
return Math.abs(a);
}
}
public class test_1_3 extends JFrame{
public static void main(String args[]){
multiple(20, 30);
dvd(20,20);
op(-20);
daoshu(2);
abs(23);
}
public static double multiple(double a, double b){
System.out.println("a*b="+a*b);
return a*b;
}
public static double dvd(double a, double b){
System.out.println("a/b="+a/b);
return a/b;
}
public static double op(double a){
System.out.println("a的相反数"+a*-1);
return a*-1;
}
public static double daoshu(double a){
System.out.println("a的倒数"+1/a);
return 1/a;
}
public static double abs(double a){
System.out.println("a的绝对值"+Math.abs(a));
return Math.abs(a);
}
}
展开全部
public static double multiple(double a, double b){return a*b;}
public static double dvd(double a, double b){return a/b;}
public static double op(double a){return a*-1;}
public static double daoshu(double a){return 1/a;}
public static double abs(double a){return Math.abs(a);}
public static double dvd(double a, double b){return a/b;}
public static double op(double a){return a*-1;}
public static double daoshu(double a){return 1/a;}
public static double abs(double a){return Math.abs(a);}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询