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

a) Method Celsius returns the Celsius equivalent of a Fahrenheit temperature, us

ID: 3838547 • Letter: A

Question

a) Method Celsius returns the Celsius equivalent of a Fahrenheit temperature, using the calculation:

b) Method Fahrenheit returns the Fahrenheit equivalent of a Celsius temperature, using the calculation:

c) Use the methods from parts (a) and (b) to write an app that enables the user either to enter a Fahrenheit temperature and display the Celsius equivalent or to enter a Celsius temperature and display the Fahrenheit equivalent.

The following is the required result

Hint:

The following is the main method with some codes missing

c=5.0 / 9.0 * ( f-32 );

Explanation / Answer

// code to add to main method
switch(choice)
{
case 1: Console.WriteLine("Celsius temperature: " + Celsius(temperature)); break;
   case 2: Console.WriteLine("Fahrenheit temperature: " + Fahrenheit(temperature)); break;
}

//These are the methods

public static int Celsius(int fahrenheitTemperature)
{
return (int)(5.0/9.0 *(fahrenheitTemperature-32));
}

public static int Fahrenheit(int celsiusTemperature)
{
return (int)(9.0/5.0 *(celsiusTemperature + 32));
}