calculator.java
来自「基于算符优先关心的」· Java 代码 · 共 33 行
JAVA
33 行
/**
* @Copyright(C) 2008 Software Engineering Laboratory (SELAB), Department of Computer
* Science, SUN YAT-SEN UNIVERSITY. All rights reserved.
**/
package parser;
import exceptions.*;
/**
* Main program of the expression based calculator ExprEval
*
* @author Yuanhang Yang 05373030
* @version 2.00 (Last update:May,23th, 2008)
**/
public class Calculator
{
/**function: calculate the result of the expression.
*
* @param expression user input to the calculator from GUI.
* @return if the expression is well-formed, return the evaluation result of it.
* @throws ExpressionException if the expression has error, a corresponding
* exception will be raised.
**/
public double calculate(String expression) throws ExpressionException
{
Parser p = new Parser(expression);
return p.parse();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?