import
java.awt.*; import
java.applet.Applet;
import
java.awt.event.*;
public
class TempConversion extends Applet implements
ActionListener {
Label CentrigradeLabel, FarenheitLabel;
TextField CentIn,
FarOut;
int f, c,
answer;
public void init(){
CentigradeLabel = new Label("Enter
Centigrade temperature ");
CentIn = new TextField(5);
FarenheitLabel = new Label ("Temperature
Farenheit ");
FarOut = new TextField(5);
add(CentigradeLabel);
add(CentIn);
CentIn.addActionListener(this);
add(FarenheitLabel);
add(FarOut);
}
public int convert(int x){
answer = (((9*x)/5)+ 32);
return answer;
}
public void actionPerformed( ActionEvent e){
if (e.getSource()==CentIn)
{
c = Integer.parseInt(CentIn.getText());
f = convert(c);
FarOut.setText(Integer.toString(f));
}
}
|