Question: - In the main class, declare and initialize two arrays as follows: Long[] salaries = {24000, 34000, 40000, 21000, 18000}; String[] profession = {nurse, teacher,

- In the main class, declare and initialize two arrays as follows: Long[] salaries = {24000, 34000, 40000, 21000, 18000}; String[] profession = {"nurse", "teacher", "Architect", "Bus Driver", "Postman"}; - Write program code to count the number of salaries in the lower range of tax, i.e. salaries below 20K. - Write program code to find a print-out the Profession with the highest Salary. 5. Encode the functionality in 4. above in a separate method that would calculate the highest value for any arbitrary array passed to it (of type long).

/* source file that contains the main function that initializes a string List and calls a method (findMax()) of another class (MaxStr) to find the longest string in the array list */

import java.util.ArrayList; import java.util.Iterator;

public class ArrayListEx { public static void main(String[] args) { // Create a dynamic list of Strings (ArrayList) and intialise it ArrayList s = new ArrayList(); s.add("potato"); s.add("cucumber"); s.add("onion"); s.add("cabbage"); s.add("mint");

//iterate through the List and print its String elements Iterator itr = s.iterator(); while(itr.hasNext()){ System.out.println(itr.next()); }

// create a sort object MaxStr myMaxStr = new MaxStr(); // call the findMax function to find the longest String String longestStr = myMaxStr.findMax(s); // print the mximum System.out.println("The longest String is: " + longestStr);

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!