Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[JAVA] Hi, I have a homework problem that requires me to create a method that takes in a HashMap and returns a double. The method

[JAVA] Hi, I have a homework problem that requires me to create a method that takes in a HashMap and returns a double. The method will return the maximum result (do not return the original value) of taking the cosine of each value from the input while considering only negative numbers from the inputs. Here's what I have so far, I am just stuck on how to return the greatest negative number. Thank you in advance for the help!!

public static double q2(HashMap hMap1) {

double getCosine = 0.0;

double getIndexValue = 0.0;

double checkValue = 0.0;

for (Map.Entry entry1 : hMap1.entrySet()) {

getIndexValue = entry1.getValue();

getCosine = Math.cos(getIndexValue);

if (getIndexValue < 0.0) {

checkValue = getCosine;

}

}

return checkValue;

}

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

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

How do callable bonds differ from retractable and extendable bonds?

Answered: 1 week ago

Question

Solve the equation 8 cosx = 5 + 2 sin x for 0 x 360.

Answered: 1 week ago