Question: Upload Chap7.java public static void main(String[] args) { String[] arguments = {Long, Not so short,Last}; int[] list1 = {1, 12, 222, 14, 987, 592}; int[]

Upload Chap7.java

public static void main(String[] args) { String[] arguments = {"Long", "Not so short","Last"}; int[] list1 = {1, 12, 222, 14, 987, 592}; int[] list2 = {6, 5, 9, 7, 4, 1}; int score = 10; // Part A. if (countLongest(args)==0) score+=5; if (countLongest(arguments)==1) score+=5; // Part B. if (countLongest(list1)==3) score+=5; if (countLongest(list2)==6) score+=5; System.out.println(score); // 10 points just to compile }

Upload Chap7.java public static void main(String[] args) { String[] arguments = {"Long",

public static void main(String[] args) [ String[] arguments {"Long", "Not so short", "Last"); int listl 1, 12, 222, 14, 987, 592); int list2 6, 5, 9, 7, 4, 1}; int score10 // Part A if (countLongest(args)--) score+-5; if (countLongest(arguments) -1) score+ 5; // Part B if (countLongest(listl)3) score+-5; if (countLongest(list2)-6) score+-5; System.out.println(score / 10 points just to compile Part A. Write a method countLongest that accepts an array of Strings as a parameter and returns the count (int) of elements in that array with length equal to the longest String in that array. See two examples above. Part B. Write a method countLongest that accepts an array of int's as a parameter and returns the count (int) of elements in that array with length (number of digits) equal to the largest int in that array. See two examples above Yes, both methods have the same name countLongest but they differ in the parameters passed, so the compiler easily knows which method to call when and how. This is commonly known as a method overload. Hints: Take a couple minutes to calm down and think. These methods are extremely similar, but two different methods. .Correct spelling, the correct form (1. return, 2. name, 3. arg), and basic use of an array are most crucial this week. .Longest String should be gauged with length) .Longest int digits can be done with> . But actual number of digits in an integer value "test" will be (int) Math.log10(test) 1

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!