Unformatted text preview: InFixExp ife = new InFixExpImp(); ife.setExp(exp); Pair<Stack<Integer>, Stack<String>> res = ife.evaluate(4); print(res.first); print(res.second); } { String exp = "3 - 2"; InFixExp ife = new InFixExpImp(); ife.setExp(exp); Pair<Stack<Integer>, Stack<String>> res = ife.evaluate(3); print(res.first); print(res.second); } { String exp = "( 3 - 2 )"; InFixExp ife = new InFixExpImp(); ife.setExp(exp); Pair<Stack<Integer>, Stack<String>> res = ife.evaluate(6); print(res.first); print(res.second); } { String exp = "( 3 - 2 ) * ( 5 % 3 ) >= ( ( 4 + 2 ) )"; InFixExp ife = new InFixExpImp(); ife.setExp(exp); Pair<Stack<Integer>, Stack<String>> res = ife.evaluate(20); print(res.first); print(res.second); } { String exp = "( 3 - 2 ) * ( 5 % 3 ) >= ( ( 4 + 2 ) )"; InFixExp ife = new InFixExpImp(); ife.setExp(exp); Pair<Stack<Integer>, Stack<String>> res = ife.evaluate(20); System.out.println(ife.toPostFix().getExp()); } { String exp = "3 - 2 ) + 5"; InFixExp ife = new InFixExpImp(); ife.setExp(exp); System.out.println("Error at: " + ife.validate()); } { String exp = "( 3 - 2 ) * 4 / 2 )"; InFixExp ife = new InFixExpImp(); ife.setExp(exp); System.out.println("Error at: " + ife.validate()); } } }...
View
Full Document
- Spring '13
- james joshi