package massiivid; import java.io.*; import java.util.Arrays; import java.util.stream.Stream; public class Sademed1 { public static void main(String[] args) throws Exception{ Double[] andmed=new Double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; //aasta summa + sademed 1..12 BufferedReader failist=new BufferedReader(new FileReader("harkutund.txt")); String esimene=failist.readLine(); String rida=failist.readLine(); double summa=0; while(rida!=null){ String[] m=rida.split(","); //System.out.println(m[0]+", "+m[3]); int kuunr=Integer.parseInt(m[0]); double arv=Double.parseDouble(m[3]); summa+=arv; andmed[0]+=arv; //Lisa sademed ka vastavale kuule andmed[kuunr]+=arv; rida=failist.readLine(); //Leia aasta sademete summa millimeetrites } System.out.println(summa+" "+andmed[0]); //Koosta massiiv, kus kohal 0 on aasta sademete summa, //kohad 1..12 aga vastavate kuude sademete summad System.out.println(Arrays.toString(andmed)); Stream.of(andmed).map(Math::round).forEach(System.out::println); } }