Question
Question 2 (35 Marks 40 Minutes) Suppose some company has many branches in different cities in a country and the administration decided to close one
Question 2 (35 Marks 40 Minutes)
Suppose some company has many branches in different cities in a country and the administration decided to close one branch because of the pandemic COVID-19 consequences. The company manager asked the financial department to prepare a report with some statistics about the employees salary in all branches. The required report should contain the sum of employees salaries in each branch. The branch with the maximum salary sum of salaries will be selected for closing.
Help the financial department in preparing the required report by developing a Java program with the following specifications:
a. Write a java method named getBranchSalariesSums that takes as an argument a double-dimensional array of type int representing the salaries of the employees in all the branches (each branch salaries are in one row). The method should return the sum of the employees salaries in all the branches as a single-dimensional array of int values.
b. In the main method,
The program reads from the user the number of branches in the company.
The program reads from the user set of rows (according to the number of branches) such that each row contains branch name and the number of employees in the branch and the salaries of the employees. The program should store the branch names in a separate single dimensional array and salaries are stored in a double-dimensional array of type int. You can consider that the number of employees in a branch is 20.
Then the program calls the method getBranchSalariesSums to compute the sums salaries of the entered employees salaries in all branches and store them in a single-dimensional array.
Finally, the program checks the sums salaries of all branches stored in the single-dimensional array to find the maximum sum and the prints the name of branch will be closed.
Sample Run:
Enter number of branches: 6
Enter branch 1 name and number of employees: Kuwait 6
Enter salaries for 6 employees in Kuwait: 222 333 444 555 666 777
Enter branch 2 name and number of employees: Egypt 5
Enter salaries for 5 employees in Egypt: 432 654 456 342 898
Enter branch 3 name and number of employees: Jordan 7
Enter salaries for 7 employees in Jordan: 432 456 523 748 598 555 333
Enter branch 4 name and number of employees: Lebanon 4
Enter salaries for 4 employees in Lebanon: 654 543 432 864
Enter branch 5 name and number of employees: Sudan 8
Enter salaries for 8 employees in Sudan: 654 678 432 234 642 432 876 598
Enter branch 6 name and number of employees: Oman 6
Enter salaries for 6 employees in Oman: 759 589 751 369 555 888
Branch: Kuwait, Emp. Salaries: 222,333,444,555,666,777, Sum Salary: 2997
Branch: Egypt, Emp. Salaries: 432,654,456,342,898, Sum Salary: 2782
Branch: Jordan, Emp. Salaries: 432,456,523,748,598,555,333, Sum Salary: 3843
Branch: Lebanon, Emp. Salaries: 654,543,432,864, Sum Salary: 2493
Branch: Sudan, Emp. Salaries: 654,678,432,234,642,432,876,598, Sum Salary: 4545
Branch: Oman, Emp. Salaries: 759,589,751,369,555,888, Sum Salary: 3911
Branch Sudan will be closed as it has the maximum salary sum which is 4545
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started