// Tyler Rigsby, CSE 142 // Scans a file of temperatures and reports the change for each day. import java.util.*; import java.io.*; public class Temperatures { public static void main(String[] args) throws FileNotFoundException { File f = new File("weather.txt"); Scanner input = new Scanner(f); double temp1 = input.nextDouble(); String garbage = ""; // while there's still tokens in the file while (input.hasNext()) { // if the next one is a double... if (input.hasNextDouble()) { double temp2 = input.nextDouble(); System.out.println(temp1 + ", " + temp2 + ", change is: " + (temp2 - temp1)); temp1 = temp2; } else { // if it's anything else... garbage += (input.next() + " "); } } System.out.println("The garbage was " + garbage); } }