Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void actionPerformed(ActionEvent e) {
- String str = e.getActionCommand();
- if (str.charAt(0) == '+' || str.charAt(0) == '-' || str.charAt(0) == '*' || str.charAt(0) == '/'){
- znak = str.charAt(0);
- p1 = Double.parseDouble(Kontener.tf.getText());
- Kontener.tf.setText("");
- }
- else if (str.charAt(0) == '='){
- p2 = Double.parseDouble(Kontener.tf.getText());
- Kontener.tf.setText("");
- switch (znak){
- case '+':
- result = p1 + p2;
- break;
- }
- Kontener.tf.setText(Double.toString(result));
- }
- else{
- Kontener.tf.setText(Kontener.tf.getText() + str);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement