JAVA数学函数基础练习

本文详细介绍了Java中常用的数学函数及其应用实例,包括三角函数、指数函数、对数函数等,并展示了如何使用这些函数进行数值计算。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/*
时间:
	2012-09-29
程序功能:
	一:了解运用数学的函数并调用求值
	二:列出了一部分函数的功能及形式
	三:采用函数调用进行输出
程序心得:
	本程序就是熟悉数学函数的;通过这几个函数的运用,基本了解了这些函数的功能以及他们的用法
	主要是要知道函数的名字很关键;否则不知道该怎么调用;调用的函数体基本上都一样,有的地方只是稍微的修改即可
	内容虽多但是写起来很简单,属于基础的部分;
*/

class Day0929_Math 
{
	public static void main(String[] args) 
	{
		show_cos();
		show_PI();
		show_sin();
		show_tan();
		show_atan();//反函数arctan
		show_asin();
		show_acos();
		show_exp();
		show_log();
		show_pow();
		show_round();
		show_sqrt();

	}
	static void show_cos()
	{
		double a;
		for (int i=0;i<30 ;i++ )
		{
			a=Math.cos(i*Math.PI/180);
			System.out.println("cos("+i+")="+a);
		}
	}
	public static void show_PI()
	{
		System.out.println("----------------");
		System.out.println("PI="+Math.PI);
	}
	static void show_sin()
	{
		int i=90;
		double a;
		a=Math.sin(i*Math.PI/180);
		System.out.println("-----------------");
		System.out.println("sin("+i+")="+a);

	}
	static void show_tan()
	{
		int i=90;
		double a;
		a=Math.tan(i*Math.PI/180);
		System.out.println("-----------------");
		System.out.println("tan("+i+")="+a);

	}
	static void show_atan()
	{
		int i=3;
		double a;
		a=Math.atan(i);
		System.out.println("-----------------");
		System.out.println("atan("+i+")="+a);

	}
	static void show_asin()
	{
		int i=3;
		double a;
		a=Math.asin(i);
		System.out.println("-----------------");
		System.out.println("asin("+i+")="+a);

	}
	static void show_acos()
	{
		int i=3;
		double a;
		a=Math.acos(i);
		System.out.println("-----------------");
		System.out.println("acos("+i+")="+a);

	}
	static void show_exp()
	{
		int i=3;
		double a;
		a=Math.exp(i);
		System.out.println("-----------------");
		System.out.println("exp("+i+")="+a);

	}
	static void show_log()
	{
		int i=3;
		double a;
		a=Math.log(i);
		System.out.println("-----------------");
		System.out.println("log("+i+")="+a);

	}
	static void show_pow()
	{
		int i=3;
		double a;
		a=Math.pow(i,3);
		System.out.println("-----------------");
		System.out.println("pow("+i+",3)="+a);

	}
	static void show_round()
	{
		int i=3;
		double a;
		a=Math.round(i);
		System.out.println("-----------------");
		System.out.println("round("+i+")="+a);

	}
	static void show_sqrt()
	{
		int i=3;
		double a;
		a=Math.sqrt(i);
		System.out.println("-----------------");
		System.out.println("sqrt("+i+")="+a);

	}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值