Check03A - fahrenheit = Integer.parseInt(buffer); if...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.Scanner; import; i public class Check03A { public static void main(String[] args) { final int ZERO_SHIFT = 32; final double SCALE_FACTOR = 5.0/9.0; f int fahrenheit; double celsius; String buffer = "a"; S Scanner input = new Scanner(; PrintStream output = System.out; P output.println("Enter the temperature in Fahrenheit"); o try t { buffer = input.nextLine();
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: fahrenheit = Integer.parseInt(buffer); if (fahrenheit <= -250) { throw new RuntimeException("Value out of Range"); } celsius = SCALE_FACTOR * (fahrenheit - ZERO_SHIFT); c output.printf("%d F = %.1f C %n", fahrenheit, celsius); o } catch (NumberFormatException nfe) { output.println("The number is not an integer. .."); } } }...
View Full Document

This note was uploaded on 09/16/2011 for the course CSE CSE 1020 taught by Professor Burton,ma during the Fall '10 term at York University.

Ask a homework question - tutors are online