tanjava代码 java tan( 四 )


他的源代码如下:
public class MainTest {public static void main(String[] args) {//求sin值double sin = Math.sin(3.14);System.out.println("sin3.14=" + sin);//求cos值double cos = Math.cos(0);System.out.println("cos0=" + cos);//求tan值double tan = Math.tan(0.785);System.out.println("tan0.785=" + tan);//求arcsindouble arcsin = Math.asin(1);System.out.println("arcsin1 = " + arcsin);//求arccosdouble arccos = Math.acos(1);System.out.println("arccos = " + arccos);//求arctandouble arctan = Math.atan(30);System.out.println("arctan30 = " + arctan);//求弧度double radians = Math.toRadians(180);System.out.println("180度角的弧度为" + radians);//求角度double angle = Math.toDegrees(3.141592653589793);System.out.println("π的角度数为" + angle);//求以e为底的指数double exp = Math.exp(1);System.out.println("以e为底指数为1的数为" + exp);//求以e为底e的平方的对数double log = Math.log(Math.E * Math.E);System.out.println("以e为底e的平方的对数" + log);//求以10为底100的对数double log10 = Math.log10(100);System.out.println("以10为底100的对数" + log10);//求100的平方根double sqrt = Math.sqrt(100);System.out.println("100的平方根是" + sqrt);//求27的立方根double cbrt = Math.cbrt(27);System.out.println("27的立方根是" + cbrt);//求10除以3的余数double rest = Math.IEEEremainder(10, 3);System.out.println("10除以3的余数为" + rest);//求0.9向上取整double ceil = Math.ceil(0.9);System.out.println("0.9向上取整" + ceil);//求2.49向下取整double floor = Math.floor(2.49);System.out.println("2.49向下取整" + floor);//求最接近参数的整数值(若有两个满足条件的数据则取为偶数的数据)double rint = Math.rint(3.5);System.out.println("最接近参数的整数值" + rint);//获得(1,1)坐标与x轴夹角度数double atan2 = Math.atan2(1, 1);System.out.println("坐标(1,1)的极坐标为" + atan2);//求3的5次方double pow = Math.pow(3, 5);System.out.println("3的5次方" + pow);//4舍5入double round = Math.round(3.5);System.out.println("3.5四舍五入为" + round);//计算2
Java编写计算器,计算器中计算sin,cos,tan的代码怎么写啊public class SanJiao {
public static void main(String[] args) {
double a = Math.toRadians(90);//把数字90 转换成 90度
System.out.println(Math.sin(a));//计算sin 90度
double b = Math.toRadians(30);
System.out.println(Math.cos(b));
double c = Math.toRadians(20);
System.out.println(Math.tan(c));
}
}
运行输出
1.0
0.8660254037844387
0.36397023426620234
tanjava代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java tan、tanjava代码的信息别忘了在本站进行查找喔 。

推荐阅读