write a program that computes weekly hours for each employee

PHOTO EMBED

Fri Apr 23 2021 07:14:21 GMT+0000 (Coordinated Universal Time)

Saved by @ahmedqgqgq #java

//import java.util.Scanner;

//write a program that computes weekly hours for each employee;
//Use a two-dimensional array.Each row records an employee's
//seven-day work hours with seven columns. 

public class Ok {
    public static int[] Sumhours(int[][] hours) {

        int TotalHoursForEachEmployee[] = new int[hours.length];
        for (int i = 0; i < hours.length; i++) {
            int sum = 0;
            for (int j = 0; j < hours[i].length; j++) {
                sum += hours[i][j];
            }
            TotalHoursForEachEmployee[i] = sum;
        }
        return TotalHoursForEachEmployee;

    }

    public static void main(String[] args) {
        // Scanner in = new Scanner(System.in);
        // int Employeeworkhours[][] = new int[7][7];
        int[][] Employeeworkhours = { 
        { 1, 2, 3, 4, 5, 6, 7 },
        { 8, 9, 10, 11, 12, 13, 14 },
        { 15, 16, 17, 18, 19, 20, 21 },
        { 22, 23, 24, 25, 26, 27, 28 },
        { 29, 30, 31, 32, 33, 34, 35 },
        { 36, 37, 38, 39, 40, 41, 42 },
        { 10, 20, 30, 40, 50, 60, 70 } };
        /*
         * for (int i = 0; i < Employeeworkhours.length; i++) { for (int j = 0; j <
         * Employeeworkhours[i].length; j++) { Employeeworkhours[i][j] = in.nextInt(); }
         * }
         */
        int total[] = Sumhours(Employeeworkhours);
        for (int i = 0; i < total.length; i++) {
            System.out.println(total[i]);
        }
    };
};
content_copyCOPY