I have this so far but I'm needing to get my values at the most to 2 decimal places but for some reason I'm drawing a blank on how to do it right now.
{
public static double celciusToFahrenheit(double celcius)
{
double fahrenheit = (9.0 / 5) * celcius + 32;
return fahrenheit;
}
public static double fahrenheitToCelcius(double fahrenheit)
{
double celcius = (5.0 / 9) * (fahrenheit - 32);
return celcius;
}
public static void main(String[] args)
{
System.out.println("Celcius\tFahrenheit\t|\tFahrenheit\tCelcius");
for (int i = 0; i < 10; i++ )
{
double celcius = 40 - i;
double convertedCelcius = celciusToFahrenheit(celcius);
double fahrenheit = 120 - (i * 10);
double convertedFahrenheit = fahrenheitToCelcius(fahrenheit);
System.out.print(celcius + "\t" + convertedCelcius + "\t|\t" + fahrenheit + "\t" + convertedFahrenheit + "\n");
}
}
}
and my result looks like this
Celcius Fahrenheit | Fahrenheit Celcius
40.0 104.0 | 120.0 48.88888888888889
39.0 102.2 | 110.0 43.333333333333336
38.0 100.4 | 100.0 37.77777777777778
37.0 98.60000000000001 | 90.0 32.22222222222222
36.0 96.8 | 80.0 26.666666666666668
35.0 95.0 | 70.0 21.11111111111111
34.0 93.2 | 60.0 15.555555555555557
33.0 91.4 | 50.0 10.0
32.0 89.6 | 40.0 4.444444444444445
31.0 87.80000000000001 | 30.0 -1.1111111111111112