weekly hours for each employee:

PHOTO EMBED

Fri Apr 23 2021 07:26:58 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];
        System.out.println("Enter employee work hours:");

        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("employee work hours:" + (i+1) + "=");
            System.out.println(total[i]);
        }
        ;
    };
};
content_copyCOPY