Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) Write a method to convert from Celsius to Fahrenheit using the following meth

ID: 3690668 • Letter: 1

Question

1) Write a method to convert from Celsius to Fahrenheit using the following method header:

// convers form Celsius to Fahrenheit

public static double celsiusToFahrenheit (double celsius)

The formula for the conversion is: Fahrenheit = ( 9/5) * Celsius +32

Write a test program that asks the user to input a Celsius value, invoke this method, then print out the corresponding Fahrenheit value.

Sample Run: Please input the temperature in Celsius: 32

32 Celsius equals to 89.6 Fahrenheit.

2) Write a test program that invokes this method several times to display the following tables using loops:

Celsius Fahrenheit

40.0 104.0

39.0 102.2

… …

32.0 89.6

31.0 87.8

Explanation / Answer

import java.util.*;

public class Conversion

{

publicn static double celsiusToFahrenheit (double celsius)

{

double f=(9.0/5.0)*celsius+32.0;

return f;

}

public static void main(String args[])

{

int i;

double c;

System.out.println("Celsius Fahrenheit");

for(i=40;i>=31;i--)

{

c=i;

System.out.println(c + " t t" +celsiusToFahrenheit(c));

}

}

}