//These are some of the standard "imports" we'll be using, explained in class
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;

public class TempConverter extends Applet implements ActionListener {

   JTextArea  output;
   JTextField input;
   JButton button;


   public void init() {

      setLayout(new BorderLayout());

      // Create the text-area and button we'll use
      input  = new JTextField(8);
      output = new JTextArea();
      button = new JButton("Convert to Fahrenheit");

      // Next we create a "panel" that we add button to
      JPanel p = new JPanel();
      p.setLayout(new FlowLayout());
      p.add(new JLabel("Enter Degrees Celsius: "));
      p.add(input);
      p.add(button);

      // Finally, to finish building the UI, we simply add the text and the panel
      // (which contains the button) to the applet
      add("Center", new JScrollPane(output));
      add("South", p);

      // Lastly, we instruct the applet to "listen" for the button to be pressed
      button.addActionListener(this);
   }

   public void actionPerformed(ActionEvent evt) {

	   // Get the input from the user, convert to number
	   float degC = Float.parseFloat(input.getText());
	  
	   // Convert to Fahrenheit
	   float degF = (degC * 9 / 5) + 32;
	   
      output.append("The Fahrenheit equivalent of " + degC + " degrees Celsius is " + degF + "\n");

   }
}
