Skip to content

Instantly share code, notes, and snippets.

@charlesreid1
Created May 15, 2017 17:52
Show Gist options
  • Save charlesreid1/3d725db43a5e04861142cb8362fefba9 to your computer and use it in GitHub Desktop.
Save charlesreid1/3d725db43a5e04861142cb8362fefba9 to your computer and use it in GitHub Desktop.
16.2 23.5
19.1 7.4 22.8
18.5 -1.8 14.9
import java.io.*;
import java.util.*;
public class WeatherData {
public static void main(String[] args) throws FileNotFoundException {
File f = new File("weather.txt");
Scanner in = new Scanner(f);
if(in.hasNextDouble()) {
double d = in.nextDouble();
while( in.hasNextDouble() ) {
double d2 = in.nextDouble();
double change = d2 - d;
System.out.printf("%.1f to %.1f, change = %.1f\n", d, d2, change);
d = d2;
}
} else {
System.out.println("Empty file!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment