Question: Write a method called max that accepts a map whose keys are strings and whose values are double as a parameter and returns the

Write a method called max that accepts a map whose keys are

Write a method called max that accepts a map whose keys are strings and whose values are double as a parameter and returns the double value that has the highest value in the map. If the map is empty, throw an exception. For example, suppose the map contains mappings from month names (strings) to the average temperature in that month (double). Your method would return the double representing the highest value. Consider a map variable monthlyTemp containing the following key/value pairs: {Jan-22.2, Feb-24.3, Mar-57.7, April-69.2, May-80.3, June-85.36, July-94.9, Aug-91.2, Sep-89.3,Oct=77. 2, Nov-48.21, Dec=18.3} a call to max(monthlyTemp) returns 94.9 since July has that temperature and that is the maximum of all the temperatures. You can assume that there are no duplicate temperatures. Hint: Use any appropriate auxillary data structure(s) as needed.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a Java method called max that accepts a map with string keys and double values and returns the ... View full answer

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

Document Format (2 attachments)

PDF file Icon

664333d3900ca_952017.pdf

180 KBs PDF File

Word file Icon

664333d3900ca_952017.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!