package main.java;
import java.util.Scanner;
import java.util.Stack;
public class Evaluate {
public static Stack<Double>stack=new Stack<Double>();
public static Stack<Character>stack1=new Stack<Character>();
public static boolean isNumeric(char c){
if((c>='0'&&c<='9')||c=='.'){
return true;
}else{
return false;
}
}
public static void cal(){
double temp=stack.peek();
stack.pop();
double temp2=stack.peek();
stack.pop();
if(stack1.peek()=='+'){
temp2+=temp;
stack.push(temp2);
}
if(stack1.peek()=='-'){
temp2-=temp;
stack.push(temp2);
} if(stack1.peek()=='*'){
temp2*=temp;
stack.push(t
Java实现用Stack实现基础的计算器
最新推荐文章于 2022-06-27 21:57:18 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)