Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please i need the answer in java using netbeans 1250 Problem #3: 125 pts Arrays and Methods We are dealing with a 1D array of

image text in transcribed

please i need the answer in java using netbeans

1250 Problem #3: 125 pts Arrays and Methods We are dealing with a 1D array of integers to store the salaries of n employees. An example is given below. 1500 3100 2600 2500 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 2500 If the salary doesn't exist, then the array of salary remains the same. Use the following method header 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 the 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started