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
//iterate through the List and print its String elements Iterator
// 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
Get step-by-step solutions from verified subject matter experts
