// Helene Martin, CSE 142 // Computes and displays the difference between pairs of // adjacent temperatures. import java.io.*; import java.util.*; public class Weather { public static void main(String[] args) throws FileNotFoundException { File weather = new File("weather.txt"); Scanner fileScan = new Scanner(weather); double temp1 = fileScan.nextDouble(); // fencepost //for (int i = 0; i < 7; i++) { // keep going as long as there are data to read while (fileScan.hasNext()) { if (fileScan.hasNextDouble()) { double temp2 = fileScan.nextDouble(); System.out.println(temp1 + " to " + temp2 + ", change = " + (temp2 - temp1)); temp1 = temp2; } else { fileScan.next(); // reads and throws away any Strings from the file } } } }