fork download
  1. import java.applet.*;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4. /* <applet code="DivideDemo" width=500 height=500> </applet? */
  5.  
  6. class DivideDemo extends Applet implements ActionListener,TextListener
  7. {
  8. Label l1,l2,l3;
  9. TextField t1,t2,t3;
  10. Button b1;
  11. int x,y;
  12. float res=0;
  13. public void init()
  14. {
  15. l1=new Label("Num1:");
  16. l2=new Label("Num2:");
  17. l3=new Label("Num3:");
  18. t1=new TextField(10);
  19. t2=new TextField(10);
  20. t3=new TextField(10);
  21. b1=new Button("Display");
  22. add(l1);
  23. add(t1);
  24. add(l2);
  25. add(t2);
  26. add(b1);
  27. add(l3);
  28. add(t3);
  29. b1.addActionListener(this);
  30. t1.addTextListener(this);
  31. t2.addTextListener(this);
  32. }
  33. public void actionPerformed(ActionEvent ae)
  34. {
  35. try
  36. {
  37. int x=Integer.parseInt(t1.getText());
  38. int y=Integer.parseInt(t2.getText());
  39. if(ae.getSource()==b1)
  40. res=x/y;
  41. }
  42. {
  43. javax.swing.JOptionPane.showMessageDialog(this, "Please enter Integer value");
  44. }
  45. {
  46. javax.swing.JOptionPane.showMessageDialog(this,"Please enter non-zero value");
  47. }
  48. t3.setText(String.valueOf(res));
  49. }
  50. public void textValueChanged(TextEvent te)
  51. {
  52. if(!t1.getText().equals("")&&(!t2.getText().equals("")))
  53. {
  54. b1.setEnabled(true);
  55.  
  56. }
  57. else
  58. b1.setEnabled(false);
  59.  
  60. }
  61. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
spoj: The program compiled successfully, but main class was not found.
      Main class should contain method: public static void main (String[] args).
stdout
Standard output is empty