Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #OS LAB1/4 made by Fensa08
- import java.io.*;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Scanner;
- public class HW01_4 {
- public static void main(String args[]) throws IOException {
- BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- FileReader file = new FileReader("rezultati.csv");
- String pole = in.readLine();
- BufferedReader bu = new BufferedReader(file);
- ArrayList<String> proseci = new ArrayList<>();
- String line = null;
- int index=0;
- float prosek = 0;
- float prosekK = 0;
- int colLen = 1;
- line = bu.readLine();
- String []pom = line.split(",");
- //Cita prv red, bara indeks na barana kolona
- for(int i = 0; i < pom.length;i++){
- if(pom[i].equals(pole)){
- index = i;
- }
- }
- while((line = bu.readLine()) != null){
- pom = line.split(",");
- prosek = 0;
- for(int i = 1; i < pom.length;i++){
- if(i == index){
- prosekK += Integer.parseInt(pom[i]);
- colLen++; // go dodava na prosekot za kolona
- }
- prosek += Integer.parseInt(pom[i]);
- }
- String linija = "Prosekot na " + pom[0] + " e: " + (prosek/(pom.length-1));
- proseci.add(linija);
- }
- String linija = "Prosekot za " + pole + " e: " + (prosekK/(colLen-1));
- proseci.add(linija);
- //Printanje podatok
- for(String i : proseci){
- System.out.println(i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement