Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 }

image text in transcribed

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

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions