Vasilena

ProgrammingExercize150321

Mar 15th, 2021 (edited)
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. public class CW150321 {
  2.     public static void main(String[] args) {
  3.         int[][] arr = {
  4.                 {5, 2, 3, 7, 12},
  5.                 {0, 6, 5, 3, 61},
  6.                 {9, 12, 0, 16, 90},
  7.                 {12, 45, 2, 13, 5},
  8.                 {7, 8, 17, 3, 14}
  9.         };
  10.  
  11.         for (int i = 0; i < arr.length; i++) {
  12.             float sumRow = 0;
  13.             int max = 0;
  14.             int min = arr[i][0];
  15.             int row = 5;
  16.             for (int j = 0; j < arr[0].length; j++) {
  17.                 sumRow = sumRow + arr[i][j];
  18.                 if(arr[i][j] > max){
  19.                     max = arr[i][j];
  20.                 }
  21.                 if(arr[i][j] < min){
  22.                     min = arr[i][j];
  23.                 }
  24.             }
  25.             float avg = sumRow/row;
  26.             System.out.println("--(●'◡'●)--Row " + (i+1) + "--(●'◡'●)--"
  27.                     + "\nSum: " + sumRow
  28.                     + "\nMaximum: "+ max
  29.                     + "\nMinimum: " +  min
  30.                     + "\nAverage: " + String.format("%.2f", avg));
  31.         }
  32.     }
  33. }
  34.  
Add Comment
Please, Sign In to add comment