Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4. The following two questions use the same Item class that we saw earlier, where each item has a name and value. The definition of

image text in transcribed

4. The following two questions use the same Item class that we saw earlier, where each item has a name and value. The definition of the Item class is shown below. public class Item { private String name; private int value; public Item(String itemName, int itemValue) { name = itemName; value = itemValue; } public String getName() { return name; } public int getValue() { return value; } } a. Write a method public static int range (Item [] [] grid) that takes a 2D array of properly instantiated Item objects as a parameter and returns the difference between the largest value and the smallest value among all the Item objects in that array. For example, if the largest value among the items in the array is 25, and the smallest value among the items in the array is 10, this method should return 15. b. Write a method public static int numEqual (Item [] [] grid) that takes a 2D array of properly instantiated Item objects as a parameter and returns the total number of those items whose value is equal to the length of its name. For example, if a certain Item in grid has a value of 5 and its name is "grape", which has five letters, that would count towards the total

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

Recommended Textbook for

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions

Question

=+ what roles should government play in them ?

Answered: 1 week ago

Question

=+ Why do we have markets and, according to economists,

Answered: 1 week ago