salary.java

සොයන්න

2.7.11

import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class salary extends Applet implements ActionListener
{
Label lbl1,lblSal,lblCal,lbl2,lblEmp;
Label lblHW,lblHR,lblGW;
TextField txt1,txt2,txt3,txt4;
Button btnCal,btnClr;


public void init()
{
setLayout(new GridLayout(8,4,25,5));
lbl1=new Label("");
lblSal=new Label("Salary");
lblCal=new Label("Calculation");
lbl2=new Label("");
lblEmp=new Label("Emp.No");
lblHW=new Label("Hours Worked");
lblHR=new Label("Hours Rate");
lblGW=new Label("Gross Wage");
txt1=new TextField(10);
txt2=new TextField(10);
txt3=new TextField(10);
txt4=new TextField(10);
btnCal=new Button("Calculate");
btnClr=new Button("Clear");

add(lblSal);
add(lblCal);
add(lbl1);
add(lbl2);
add(lblEmp);
add(txt1);
add(lblHW);
add(txt2);
add(lblHR);
add(txt3);
add(lblGW);
add(txt4);
add(btnCal);
add(btnClr);
btnCal.addActionListener(this);
btnClr.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
int HW,HR,GW;
if(e.getSource()==btnCal)
{
HW=Integer.parseInt(txt2.getText());
HR=Integer.parseInt(txt3.getText());
GW=HW*HR;
txt3.setText(String.valueOf(GW));
}
else
{
txt1.setText("");
txt2.setText("");
txt3.setText("");
txt4.setText("");
}
}
}

0 comments:

Post a Comment

පරිගණක උදවු ගැන ඔබේ අදහස

There was an error in this gadget

PCWorld නවතම පුවත්