/** * Converts Fahrenheit to Celsius and from miles per hour to km per hour * * Illustrates * - Using parenthesis to enforce order of operations * - Division with floating point numbers * * @author alchambers */ public class Conversions{ public static void main(String[] args){ // The equation for converting fahrenheit to celsius: // C = (F - 32) * 5/9 int freezingPoint = 32; double conversionRatio = 5.0/9.0; double fahrenheit = 50.0; double celsius = (fahrenheit - freezingPoint) * conversionRatio; System.out.println(fahrenheit + " degrees fahrenheit equals " + celsius + " degrees celsius"); // The conversion factor between mph and km/h is // 1 mph = 1.60935 km/h double conversionFactor = 1.60935; double milesPerHour = 60.0; double kmPerHour = milesPerHour * conversionFactor; System.out.println(milesPerHour + " mph equals " + kmPerHour + " km/h"); } }