Java Homework please help
#1
Java Homework please help
So for extra credit i need to make this temperature conversion applet allow user to input either degrees C* of F* and output the opposite unit.
this is what i have so far. Any suggestions
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class TempConvert extends Applet implements ActionListener
{
double F, C;
Label prompt;
TextField input;
public void init()
{
prompt = new Label ("Enter the Temperature in degrees fahreinheit:");
add(prompt);
input = new TextField(5);
add(input);
input.addActionListener(this);
}
public void actionPerformed (ActionEvent e)
{
F = Integer.parseInt(input.getText());
C = F - 32 * 5 / 9;
repaint();
}
public void paint (Graphics g)
{
g.drawString ("the current Temperature is " + C +"degrees celcius.",70,75);
setBackground(Color.green);
}
}
this is what i have so far. Any suggestions
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class TempConvert extends Applet implements ActionListener
{
double F, C;
Label prompt;
TextField input;
public void init()
{
prompt = new Label ("Enter the Temperature in degrees fahreinheit:");
add(prompt);
input = new TextField(5);
add(input);
input.addActionListener(this);
}
public void actionPerformed (ActionEvent e)
{
F = Integer.parseInt(input.getText());
C = F - 32 * 5 / 9;
repaint();
}
public void paint (Graphics g)
{
g.drawString ("the current Temperature is " + C +"degrees celcius.",70,75);
setBackground(Color.green);
}
}
Thread
Thread Starter
Forum
Replies
Last Post
java09
Scion tC 1G ICE & Interior
99
10-14-2009 04:49 PM
java09
Scion tC 1G Forced Induction
2127
09-24-2009 03:40 PM
YELOSUB
Scion xA/xB 1st-Gen Wheel & Tire
2
07-17-2006 01:57 AM
dante
Buyer / Seller Experiences
53
11-30-2004 08:23 PM