Question: Please use Java PART 2 Problem #3: (25 pts) Arrays and Methods We are dealing with a ID array of integers to store the salaries
Please use Java
PART 2 Problem #3: (25 pts) Arrays and Methods We are dealing with a ID array of integers to store the salaries of n employees. An example is given below. 1250 1500 3100 2500 2600 Develop an application that contains the following methods: . [5 pts) A method to output the array elements separated by a "-". Use the following method header public static void printArray! int[] arr) . [10 pts) A method to remove a given salary from the array, This method accepts as parameters an arrays of integers (salaries) and an integer parameter representing the salary to be removed from the array. The method searches whether that salary exists in the array. If this salary exists, it should replace it with a zero. For example, if we want to remove the salary 3100, then the array will be changed as follows arr before the call 1250 1500 3100 2600 2500 Arr after the call 1250 1500 0 2600 If the salary docsn't exist, then the array of salary remains the same. Use the following method header: 2500 public static void remove(int arr, int salary) . [10 pts) A main method to test the above methods on an array of n salaries (n is given by user). You should ask the user to fill the array elements. Then the program should: - Invoke the method printArray to display the values stored in the array. - Invoke the method remove to remove a given salary from the array. - Invoke the method printArray to display the values after calling remove. Sample run: Enter n: 5 Enter 5 salaries: 1250 1500 3100 2600 2500 The elements in he array are: 1250 - 1500 - 3100 - 2600 - 2500 Enter a salary to remove: 3100 1250 - 1500 - 0 - 2600 - 2500
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
