/** * Matt Kretchmar * cs171 * January 10, 2006 * * This program converts temperatures in Fahrenheit to Celsius. It * rounds the output to the nearest whole number. */ import java.util.Scanner; import java.math.*; public class Temperature { public static void main (String args[]) { int tempFahrenheit; int tempCelsius; Scanner keyboard; keyboard = new Scanner(System.in); // Prompt the user for input temperature: System.out.println("Enter a temperature in Fahrenheit:"); tempFahrenheit = keyboard.nextInt(); // Compute temperature in celsius tempCelsius = (int) Math.round( (tempFahrenheit - 32.0) * 5.0 / 9.0 ); // Display the output: System.out.println(tempFahrenheit+"F = " + tempCelsius + "C"); } }