import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;

  public class Pay extends Applet implements ActionListener
  {
     private Label l1, l2, l3;
     private Button one, two, three, four;
     private TextField wages, h;
     private int salary, hours, time;
     private boolean o = false;
     private boolean t = false;
     private boolean t3 = false;
     private boolean t4 = false;

     public void init()
     {
       setLayout(null);

       l1 = new Label("Select employee's paycode : ");
       add(l1);
       l1.setBounds(10,80,200,20);

       l2 = new Label("Enter salary : ");
       add(l2);
       l2.setBounds(10,10,80,20);

       l3 = new Label("For hourly workers, enter hours");
       add(l3);
       l3.setBounds(220,10,100,20);

       one = new Button("1");
       add(one);
       one.addActionListener(this);
       one.setBounds(210,110,40,20);

       two = new Button("2");
       add(two);
       two.addActionListener(this);
       two.setBounds(150,110,40,20);

       three = new Button("3");
       add(three);
       three.addActionListener(this);
       three.setBounds(90,110,40,20);

       four = new Button("4");
       add(four);
       four.addActionListener(this);
       four.setBounds(30,110,40,20);

       wages = new TextField(5);
       add(wages);
       wages.setBounds(100,10,100,20);
       
       h = new TextField(5);
       add(h);
       h.setBounds(220,40,100,20);
     }

      public void paint(Graphics g)
      {
        if (o)         
         {
          g.drawString("The employee's salary is : "+salary*5+" a week",30,180);
          g.drawString("Manager post",30,50);
         }

        else if (t)        
        {
         hours = salary*time;
         g.drawString("The employee's salary is : "+hours,30,180);
         g.drawString("Hourly worker post",30,50);
        }

       else if(t3)
       {
        float p = 5.7f/100;
        int sum = salary+250;
        g.drawString("Commision workers",30,50);
        g.drawString("The employee's salary is : "+sum+p,30,180);

       }

       else if(t4)
       {
        g.drawString("Pieceworkers post",30,50);
        g.drawString("The employee's salary is : "+salary,30,180);
    
       }

       else
        repaint(); 
     }
       public void actionPerformed(ActionEvent event)
       {
    
         salary = Integer.parseInt(wages.getText());
         time = Integer.parseInt(h.getText());

         if (event.getSource()==one)
    
          o = true;         

         if (event.getSource()==two)
          t = true;

         if (event.getSource()==three)
          t3 = true;

         if (event.getSource()==four)
          t4 = true;

         repaint();
       }

  }
