2022-01-23

File reader finding the average of the values from a txt file of the rows and columns without using arrays

I am given a txt file 7x3 grid of values and I'm supposed to find the average of each rows (7) and columns (3) without using arrays. The professor has guided us to printing the grid out but I'm not sure what to do next.

public static void main (String [] args){
    try{
        File file = new File("Cal.txt");
        Scanner scanFile = new Scanner(file);
        for (int i = 0; i < 7; i++){
            String string = scanFile.nextLine();
            System.out.println(string);
                    
        }

    }catch(Exception e) {
        System.out.println("Error occured...");
    }

}

The grid:

 40.0 30 10 
 25 76 1120
 0 1301 1823
 630 300 1000
 102 1100 1900
 982 200 239
 200 720 100


from Recent Questions - Stack Overflow https://ift.tt/3GSyfTe
https://ift.tt/eA8V8J

No comments:

Post a Comment