I have tried c and f both as double and int. Thanks for your input!
Task: Display table of Celsius temp 0 - 20 and Fahrenheit equivalent
public class CelsiusToFahrenheit
{
public static void main(String[] args)
{
int c = 0;
int f;
System.out.println("Celsius Fahrenheit");
System.out.println("--------------------");
while (c <= 20; c ++); //c = 0 or 1?
{
f = 9.0*c/5+32;
System.out.println(" " +c+ " "+f);
}
}
//this is how it is in chpt 5, but doesn't appear to do anything different
static int f (int c)
{
int f;
f = (9.0/5.0)*c+32;
return f;
}
}
The results are below. Where's the rest???
/*
C F
-----------------------
21.0 69.8
Press any key to continue . . .
*/

New Topic/Question
Reply



MultiQuote



|