/*
This program will convert Celsius to Fahrenheit and display a table
of their Fahrenheit equivalents.
*/
// ---------1---------2---------3---------4---------5--------6---------7
// 1234567890123456789012345678901234567890123456789012345678901234567890
public class CelsiusToFarhenheit
{
public static void main(String[] args)
{
//Variables
float fhdeg;
float celdeg = 0;
while (celdeg <= 20)
{
fhdeg = 1.8 * celdeg + 32;
}
if (celdeg <= 20)
{
System.out.printf( " %3d C = %5.1f F\n", celdeg, fhdeg );
celdeg++;
}
}
}
I keep getting this error...
CelsiusToFarhenheit.java:22: error: incompatible types: possible lossy conversion from double to float fhdeg = 1.8 * celdeg + 32; ^ 1 error
what I don't get is if i'm initializing them as floats...what's going on? and since I can't get it to initialize, i'm unaware of whether I have any other errors or if it will even print out the table the way I would like.