fork(2) download
  1. import java.awt.FlowLayout;
  2.  
  3. import javax.swing.*;
  4.  
  5. public class calc_97_lvl {
  6.  
  7. public static JLabel jlab;
  8.  
  9. calc_97_lvl() {
  10.  
  11. ListenCalc LC=new ListenCalc();
  12.  
  13. JFrame jfrm=new JFrame("Калькулятор Кузнецова");
  14. jfrm.setSize(185,157);
  15. jfrm.setLayout(new FlowLayout());
  16. jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  17. jfrm.setVisible(true);
  18. JLabel jlab=new JLabel();
  19. jlab.setText("egeherjrj!");
  20. jlab.setSize(150, 150);
  21.  
  22. JButton but1=new JButton("+");
  23. JButton but2=new JButton("-");
  24. JButton but3=new JButton("*");
  25. JButton but4=new JButton("/");
  26. JButton but5=new JButton(".");
  27. JButton but6=new JButton("e");
  28. JButton but7=new JButton("=");
  29.  
  30. JButton b1=new JButton("1");
  31. JButton b2=new JButton("2");
  32. JButton b3=new JButton("3");
  33. JButton b4=new JButton("4");
  34. JButton b5=new JButton("5");
  35. JButton b6=new JButton("6");
  36. JButton b7=new JButton("7");
  37. JButton b8=new JButton("8");
  38. JButton b9=new JButton("9");
  39. JButton b0=new JButton("0");
  40.  
  41. but1.addActionListener(LC);
  42. but2.addActionListener(LC);
  43. but3.addActionListener(LC);
  44. but4.addActionListener(LC);
  45. but5.addActionListener(LC);
  46. but6.addActionListener(LC);
  47. but7.addActionListener(LC);
  48.  
  49. b1.addActionListener(LC);
  50. b2.addActionListener(LC);
  51. b3.addActionListener(LC);
  52. b4.addActionListener(LC);
  53. b5.addActionListener(LC);
  54. b6.addActionListener(LC);
  55. b7.addActionListener(LC);
  56. b8.addActionListener(LC);
  57. b9.addActionListener(LC);
  58. b0.addActionListener(LC);
  59.  
  60. jfrm.add(jlab);
  61. jfrm.add(b1);
  62. jfrm.add(b2);
  63. jfrm.add(b3);
  64. jfrm.add(but1);
  65. jfrm.add(b4);
  66. jfrm.add(b5);
  67. jfrm.add(b6);
  68. jfrm.add(but2);
  69. jfrm.add(b7);
  70. jfrm.add(b8);
  71. jfrm.add(b9);
  72. jfrm.add(but3);
  73. jfrm.add(but5);
  74. jfrm.add(b0);
  75. jfrm.add(but6);
  76. jfrm.add(but7);
  77.  
  78. }
  79. public void set_jlab(String newText){jlab.setText(newText);}
  80. public static void main(String[] args){
  81. SwingUtilities.invokeLater(new Runnable(){
  82. public void run(){
  83. new calc_97_lvl();
  84. }
  85. });
  86. }}
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97. import java.awt.event.ActionEvent;
  98. import java.awt.event.ActionListener;
  99. import java.util.StringTokenizer;
  100.  
  101.  
  102. public class ListenCalc implements ActionListener {
  103.  
  104.  
  105. double numberResult;
  106.  
  107. public void actionPerformed(ActionEvent ae){
  108. resultGiver(ae.getActionCommand());
  109. }
  110.  
  111. public double resultGiver(String textResult){
  112. StringTokenizer ST=new StringTokenizer(textResult, "+-*/e",true);
  113.  
  114. String s1=ST.nextToken();
  115. String s2=ST.nextToken();
  116. String s3=ST.nextToken();
  117. double op1=Double.parseDouble(s1);
  118. double op2=Double.parseDouble(s3);
  119. if(s2.equals("+")){numberResult=op1+op2;}
  120. else if(s2.equals("-")){numberResult=op1-op2;}
  121. else if(s2.equals("*")){numberResult=op1*op2;}
  122. else if(s2.equals("/")){numberResult=op1/op2;}
  123. else{}
  124. return 0;
  125. }
  126. }
  127.  
  128.  
  129.  
  130.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:97: class, interface, or enum expected
import java.awt.event.ActionEvent;
^
Main.java:98: class, interface, or enum expected
import java.awt.event.ActionListener;
^
Main.java:99: class, interface, or enum expected
import java.util.StringTokenizer;
^
3 errors
stdout
Standard output is empty