Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (e.getSource() == Calc.eqls) {
- curText = Calc.tf.getText();
- if(curText.contains("*")) {
- if(curText.contains("+")) {
- int add = curText.indexOf("+");
- Calc.tf.setText((curText.substring(add-1)+curText.substring(add+1)));
- }
- else if(curText.contains("-")) {
- int subtr = curText.indexOf("-");
- Calc.tf.setText((curText.substring(subtr-1)+curText.substring(subtr-1)));
- }
- }
- else if(curText.contains("+")) {
- int add = curText.indexOf("+");
- int result = Integer.parseInt(curText.substring(add-1)) + Integer.parseInt(curText.substring(add+1));
- String result2 = Integer.toString(result);
- Calc.tf.setText(result2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement