Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. if (!TF1.getText().contains(".")) // if the text dont contain .
  2. {
  3. if(TF1.getText().equals(0)&& !butt.getText().equals("."))
  4. {
  5. //if the jtext contain only 0 clear the text
  6. // and the button pressed is not '.'
  7. TF1.setText(butt.getText());
  8. isOprClick=false;
  9. }
  10. else
  11. {
  12. TF1.setText(TF1.getText()+butt.getText());
  13. }
  14. }
  15. else if (!butt.getText().equals("."))
  16. {
  17. TF1.setText(TF1.getText()+butt.getText());
  18. isOprClick=false;
  19. }
  20. }
  21. else // if the button is an opr -+*/=
  22. {
  23. if(operclickcount==0) //if an operation is clicked for the first time
  24. {
  25. operclickcount++;
  26. //convert the textfield to float and set in n1
  27. n1=Float.valueOf(TF1.getText());
  28. opr=butt.getText();
  29. isOprClick=true;
  30. } else
  31. {
  32. if (!butt.getText().equals("=")) //if the operation is not "="
  33. {
  34. if(! isEqualsClick)
  35. {
  36. n2=Float.valueOf(TF1.getText());
  37. TF1.setText(Float.toString(calc(opr, n1, n2)));
  38. opr=butt.getText();
  39. n2=Float.valueOf(TF1.getText());
  40. isOprClick=true;
  41. isEqualsClick=false;
  42. } else
  43. {
  44. isEqualsClick=false;
  45. opr=butt.getText();
  46. }
  47.  
  48. }
  49. else
  50. {
  51. n2= Float.valueOf(TF1.getText());
  52. TF1.setText(Float.toString(calc(opr, n1, n2)));
  53. n1= Float.valueOf(TF1.getText());
  54. isOprClick=true;
  55. isEqualsClick=true;
  56.  
  57. }
  58. }
  59. }
  60. };
  61. return acLis ;
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement