Notices
Off-topic Cafe Meet the others and talk about whatever...

Java Homework please help

Thread Tools
 
Search this Thread
 
Old 03-01-2007, 05:07 PM
  #1  
Senior Member
10 Year Member
5 Year Member
SL Member
Thread Starter
 
XB_BOB's Avatar
 
Join Date: Jul 2005
Location: Frederick MD
Posts: 153
Default 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);
}
}
XB_BOB is offline  
Old 03-01-2007, 05:12 PM
  #2  
Senior Member
10 Year Member
5 Year Member

SL Member
 
kanundrum's Avatar
 
Join Date: Jun 2005
Location: Laurel, MD
Posts: 5,114
Default

I got the psuedo code at home and this written in C++. Ill post up when I get home it should help, the only other problem would be any syntax errors.
kanundrum is offline  
Related Topics
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
pixiedixie862
Regional - Pacific South
14
11-05-2007 10:11 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



Quick Reply: Java Homework please help



All times are GMT. The time now is 05:21 AM.