// Zorah Fung, CSE 142 // Prints out the temperature for today and the weekend. // // Note: We didn't write this in class, but this shows that you can use methods that // return to make your code more readable -- reading a method name is easier than a complex // expression -- and to reduce redundancy so the code to compute the conversion from // farenheit to celcius is only in one place. public class Temperatures { public static void main(String[] args) { double currentTemp = 72; double weekendTemp = 90; System.out.println("It's currently " + currentTemp + "F (" + fToC(currentTemp) + "C)"); System.out.println("This weekend, it will be " + weekendTemp + "F (" + fToC(weekendTemp) + "C)"); } // Given a temperature in farenheit, returns the temperature in Celcius public static double fToC(double farenheit) { return (5.0 / 9.0 * (farenheit - 32)); } }