简单计算器(个位数之间的带括号的四则运算)
初步实现,优化整数范围内的四则运算,之后实现简单的浮点型的四则运算
public class test {
public static void main(String[] args) {
ArrayStack numstack=new ArrayStack(20);
ArrayStack operstack=new ArrayStack(20);
String str="((3+6)*(3+4))"; //计算的四则运算
int index=0;
int num1=0; //参与运算的整数
int num2=0;
int oper=0; //参与运算的符号
int res=0;
char ch=' ';
while(true) {
// 循环按位扫描
ch=str.substring(index,index+1).charAt(0);
if(operstack.isOper(ch)) {
//判断是否是字符
if(!operstack.isEmpty()) {
//判断符号栈是否为空
if(ch==')') {
while(operstack.peek()!='(') {
num1=numstack.pop();
num2=numstack.