⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mymath.java

📁 Spring2.0宝典
💻 JAVA
字号:
package lee;

import java.lang.Math;

/**
 * @author  yeeku.H.lee kongyeeku@163.com
 * @version  1.0
 * <br>Copyright (C), 2005-2008, yeeku.H.Lee
 * <br>This program is protected by copyright laws.
 * <br>Program Name:
 * <br>Date: 
 */
public class MyMath
{
    public double oneEquation(double a , double b)throws MyMathException
	{
		if (a == 0)
		{
			System.out.println("参数错误");
			throw new MyMathException("参数错误");
		}
		else
		{
			return -b/a;
		}

    }

    public double[] twoEquation(double a , double b , double c)throws MyMathException
	{
		double[] result ;
		if (a == 0)
		{
			System.out.println("参数错误");
			throw new MyMathException("参数错误");
		}
		else if(b * b - 4 * a * c < 0)
		{
			System.out.println("方程在有理数范围内无解");
			result = null;
			return result;
		}
		else if(b * b - 4 * a * c == 0)
		{
			System.out.println("方程在有唯一解");
			result = new double[1];
			result[0] = -b/(2 * a);
			return result;
		}
		else
		{
			System.out.println("方程在有两个解");
			result = new double[2];
			result[0] = (-b + Math.sqrt(b * b - 4 * a * c))/2/a;
			result[1] = (-b - Math.sqrt(b * b - 4 * a * c))/2/a;
			return result;
		}
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -