write java program using table that stores celsius and farenheit values that are equal to one another using a loop. use C 0-20 and convert to farenheit.
I have to use doubles for Celsius and Fahrenheit and in the formula.
I get a runtime error with the following displayed:
I will display a table of temperatures in their Celsius and Farenheit equivalents.
celsius farenheit
--------------------
/* This is my fifth homework */
import java.util.*;
import java.lang.*;
import java.io.*;
class TemperatureConversion
{
public static void main (String[] args) throws java.lang.Exception
{
double celsius; // Temperature in degrees Celsius minimum
double farenheit; // Temperature in degrees Fahrenheit
System.out.println("I will display a table of temperatures " +
"in their Celsius and Farenheit equivalents.");
//Display the degree equivalency headings.
System.out.println("celsius\t\tfarenheit");
System.out.println("--------------------");
//Display the temperatures.
for (celsius = 0; celsius <= 20; celsius++)
{
//Convert to Farenheit
farenheit = celsius*(9/5)+32;
//Display degrees in two equivalencies.
System.out.printf("%d\t\t%.1f\n", celsius, farenheit);
}
}
}