// Yazzy Latif // 7/27/2020 // CSE142 // TA: Grace Hopper // Prints out the change in temperature between days given by data stored in a file. Ignores // tokens that are not real numbers. import java.util.*; import java.io.*; public class Weather { public static void main(String[] args) throws FileNotFoundException { Scanner input = new Scanner(new File("weather.txt")); double temp1 = input.nextDouble(); // fencepost problem! // n numbers we want to read // n - 1 differences to compute while (input.hasNextDouble()) { double temp2 = input.nextDouble(); System.out.println("temp1: " + temp1 + ", temp2: " + temp2 + ", difference: " + (temp2 - temp1)); temp1 = temp2; } } }