// Helene Martin, CSE 142 // Reads temperatures from a data file with comments // Displays the difference in temperature between // adjacent data points. 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("weather2.txt")); double t1 = input.nextDouble(); // fencepost while (input.hasNext()) { if (input.hasNextDouble()) { double t2 = input.nextDouble(); System.out.println(t1 + " to " + t2 + ", change = " + (t2 - t1)); t1 = t2; } else { input.next(); // advance beyond "bad" tokens } } } }