How to construct a loop that produces a temp conversion chart

Try something like this:

System.out.println( "Farenheit | Celsius  | Kelvin" );
// For loop
for ( double f = startfarh ; f <= endfarh ; f += 1d )
{
    double c = ( f - 32 ) / 1.8d;
    double k = c + 273.15;
    System.out.printf( "%7.2f°F = %6.2f°C = %6.2fK%n", f, c, k );
}

Leave a Comment