// Helene Martin, CSE 142 // Displays changes in temperature based on a data file. import java.io.*; import java.util.*; public class Temperatures { public static void main(String[] args) throws FileNotFoundException { //File f = new File("weather.txt"); Scanner input = new Scanner(new File("weather.txt")); double temp1 = input.nextDouble(); //for (int i = 0; i < 7; i++) { only works for one file! while (input.hasNext()) { // read until the very end of the file if (input.hasNextDouble()) { // only process doubles double temp2 = input.nextDouble(); System.out.println(temp1 + " to " + temp2 + ", change = " + (temp2 - temp1)); temp1 = temp2; } else { input.next(); // discard any non-double } } } }