/* * This program does temperature conversions. * It can convert from Fahrenheit to Celsius or from Celsius * to Fahrenheit, at the user's preference. */ import tio.*; class Convert { public static void main(String[] args) { double fahrenheit = 0.0, celsius; = 0.0; boolean keepGoing = true; char conversion; // Keep doing conversions until the user says to stop while(keepGoing) { // Ask the user which conversion to perform System.out.println("Please enter F for Fahrenheit to Celsius" + " conversion\n or C for Celsius to " + "Fahrenheit conversion"); conversion = (char)Console.in.readChar(); Console.in.readChar(); // To get rid of the newline // Perform the conversion, depending upon what the user entered if(conversion == 'F' || conversion == 'f') { // Perform the F to C conversion System.out.print("Please enter the Fahrenheit temperature: "); fahrenheit = console.in.readDouble(); celsius = (5/9) * (fahrenheit - 32); System.out.println(fahrenheit + " Fahrenheit = " + celsiue + "Celsius"); } else { // Perform the C to F conversion System.out.print("Please enter the Celsius temperature: "); celsius = console.in.readDouble(); fahrenheit = ((9/5) * celsius) + 32; System.out.println(fahrenheit + " Fahrenheit = " + celsiue + "Celsius"); } } } }