/* CSE 142, Autumn 2007, Marty Stepp This program reads a file of temperatures and displays the change in temperature between neighboring days. It is an example of an "inchworm" fencepost solution. */ import java.io.*; import java.util.*; // for Scanner public class Temperatures { public static void main(String[] args) throws FileNotFoundException { Scanner input = new Scanner(new File("temps.txt")); // need to examine 2 numbers at each pass, but only advance by 1 int temp1 = input.nextInt(); while (input.hasNextInt()) { int temp2 = input.nextInt(); System.out.println("Temp changed by " + (temp2 - temp1) + " deg F"); temp1 = temp2; } } }