Hi guys,
I'm new to this forum and I'm excited to learn more about java with your help
I'm learning how to read numbers from file.
in this coding, I want to read floats from file and calculate minimum and maximum temperatures from it and get a output like this :
-10 ≤ temp < 0
0 ≤ temp < 10
10 ≤ temp < 20
20 ≤ temp < 30
30 ≤ temp < 40
here are my coding:
import java.util.*; import java.io.*; public class max { public static void main(String[] args) { if (0 < args.length) { File test = new File(args[0]); Scanner t = new Scanner( new FileInputStream(test)); while(t.hasNextFloat()){ float x = t.nextFloat(); System.out.println(x); } }
and here an example of my file:
12.8701128 -19.08983034 37.95429681 51.67538099 14.815839 8.192769202 -16.12037567 58.16092338 43.11540189 -3.681658176 59.099608 9.176666748 21.34655982 9.509843699 2.620998417 56.92736179 -11.9657946 66.29716149 5.732177907 -14.88076519 -11.43389073 55.27621116 49.09869394 45.01297259
any idea how can I separate minimum and maximum of each raw and print it like above?
thank you