Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- public class Frankie2 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- String fileName = "haberman.csv";
- File file = new File(fileName);
- try {
- Scanner inputStream = new Scanner(file);
- int counter = 0;
- int[] auxNode = new int[306];
- int[] survTime = new int[306];
- while (inputStream.hasNext()){
- String data = inputStream.next(); //retrieves entire line
- String[]values = data.split(",");
- auxNode[counter] = Integer.parseInt(values[2]);
- survTime[counter] = Integer.parseInt(values[3]);
- counter++;
- }
- for (int i = 0; i < auxNode.length; i++){
- System.out.println(auxNode[i]);
- }
- System.out.println("PENIS");
- for (int i = 0; i < survTime.length; i++){
- System.out.println(survTime[i]);
- }
- double sumAuxNodel = 0; //sum of all aux nodes <5
- double sumAuxNodeu = 0; // sum of all aux nodes >5
- double survTimel = 0; //how many survival times <5
- double survTimeu = 0; //how many survival times >5
- for (int i = 0; i < survTime.length; i++){
- if (survTime[i] == 1){
- sumAuxNodeu += auxNode[i];
- survTimeu += 1;
- }
- if (survTime[i] == 2){
- sumAuxNodel += auxNode[i];
- survTimel += 1;
- }
- }
- System.out.println("Average Aux Node of people with a survival time less than 5 years is" + sumAuxNodel/survTimel + "Nodes");
- System.out.println("Average Aux Node of people with a survival time less than 5 years is" + sumAuxNodeu/survTimeu + "Nodes");
- inputStream.close();
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement