Temperature conversion not working can someone help me.

import java.awt.Graphics;// program uses class Graphics

import javax.swing.JApplet; // program uses class JApplet

import javax.swing.JOptionPane;

public class Temp1 extends JApplet

{

// draw text on applet's background

public void paint( Graphics g )

{

// call superclass version of method paint

super.paint( g );

int cels;

for (int fahr = 0; fahr <= 212; fahr++ )

{

cels = 5.0 / 9.0 * (fahr - 32);

System.out.printf( "%df\n", cels);

g.drawString( "Is then converted to" + cels + "degrees Celsius", 25, 25 );

}

} // end method paint

} // end class WelcomeApplet

it does give me one error its says possible loss of precision on line 15, the cels = 5.0 / 9.0 * (fahr - 32); line

[801 byte] By [I_Need_Java_helpa] at [2007-11-27 4:08:55]
# 1

You're basically doing this:

int i = 1.5;

Obviously, you can't put 1.5 into an int, so it will get truncated down to 1. However, the compiler is forcing you to either fix it or tell it that you really want to truncate the double to an int.

double d = 1.5;

OR

int i = (int)1.5;

jverda at 2007-7-12 9:14:18 > top of Java-index,Java Essentials,Java Programming...