// Reads a file of temperaturens and outputs the difference // between each pair of temperatures. import java.io.*; // file import java.util.*; // scanner public class Temperatures { public static void main(String[] args) throws FileNotFoundException { Scanner input = new Scanner(new File("temp.txt")); // fencepost problem -- must read one int outside loop int temp1 = input.nextInt(); while (input.hasNextInt()) { int temp2 = input.nextInt(); System.out.println("Temperature changed by " + (temp2 - temp1) + " deg F"); temp1 = temp2; } } }