Advertisement
Guest User

Untitled

a guest
May 2nd, 2012
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1.  
  2. if (e.getSource() == Calc.eqls) {
  3. curText = Calc.tf.getText();
  4. if(curText.contains("*")) {
  5. if(curText.contains("+")) {
  6. int add = curText.indexOf("+");
  7. Calc.tf.setText((curText.substring(add-1)+curText.substring(add+1)));
  8. }
  9. else if(curText.contains("-")) {
  10. int subtr = curText.indexOf("-");
  11. Calc.tf.setText((curText.substring(subtr-1)+curText.substring(subtr-1)));
  12. }
  13. }
  14. else if(curText.contains("+")) {
  15. int add = curText.indexOf("+");
  16. int result = Integer.parseInt(curText.substring(add-1)) + Integer.parseInt(curText.substring(add+1));
  17. String result2 = Integer.toString(result);
  18. Calc.tf.setText(result2);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement