I'm trying to create a java applet that displays farhen and cels temperatures in a chart. Temps below freezing need to be displayed in blue, and about boiling displayed in red. It needs to use applet graphics to draw the strings in different colors but I'm fairly lost when it comes to using different methods together. I don't know how I can draw a string based on a farhen temp while also incrementing farhen at the same time in seperate method.
Trust me I know this is really wrong I just don't know how to base drawstring color on my farhen variable.
import java.awt.*;
import java.applet.*;
public class TempConv extends Applet
{
public static void main ( String[] args )
{
System.out.println("Temperature Conversion Chart");
}
public void paint( Graphics g )
{
this.setBackground( Color.lightGray );
g.setColor ( Color.black);
g.drawString( "Fahrenheit" + " " + "Clesius", 10, 15 );
g.setColor( Color.red );
g.drawLine( 12, 30, 200, 30);
int col = 15;
int row = 20;
float farhen = 0;
float cels;
for (int i = 0; i < 25; i++){
if (farhen < 32){
cels = ( 5 ÷ 9 ) × ( farhen - 32 );
g.setColor ( Color.blue );
g.drawString( " " + farhen + "\u2109" + " " + cels + "\u2103", col, row );
farhen += 10;
row += 14;
}
else if{
cels = ( 5 ÷ 9 ) × ( farhen - 32 );
g.setColor ( Color.black );
g.drawString( " " + farhen + "\u2109" + " " + cels + "\u2103", col, row );
farhen += 10;
row += 14;
}
else{
cels = ( 5 ÷ 9 ) × ( farhen - 32 );
g.setColor ( Color.black );
g.drawString( " " + farhen + "\u2109" + " " + cels + "\u2103", col, row );
farhen += 10;
row += 14;
}
}
I also need to format the output to make them all whole number but I think keeping the temps as int will do that. Any help is appreciated.