Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The method findLargest should return the largest of any number of double values. For example, the call findLargest (3.4, -2.6, 2.9) should return 3.4 and

The method findLargest should return the largest of any number of double values. For example, the call findLargest (3.4, -2.6, 2.9) should return 3.4 and the call findLargest (9.2, 17.6, 3.4, -2.6, 2.9) should return 17.6. Partial code to do this is given below:

double findLargest (double... values)
{
 double max = values[0];
 // New code goes here 
 return max;
}

What code will complete this method?

A)

for (double val: values)
{
 if (val > max)
 {
 max = val;
 }
}

B)

for (int i = 1; i < values.length; i++)
{
 if (i > max)
 {
 max = i;
 }
}

C)

for (double val:values)
{
 if (values[val] > max)
 {
 max = values[val];
 }
}

D)

for (int i = 1; i < values.length; i++)
{
 if (values[i] > max)
 {
 max = i;
 }
}

Please give an explanation!

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

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago