Created
May 15, 2017 17:52
-
-
Save charlesreid1/3d725db43a5e04861142cb8362fefba9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16.2 23.5 | |
19.1 7.4 22.8 | |
18.5 -1.8 14.9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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