Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define five new Java methods that each take three double values as parameters. Each method returns a result. None of these methods read from user

Define five new Java methods that each take three double values as parameters. Each method returns a result. None of these methods read from user input, and none of these methods prints to the console.

1) smallest()

This method takes three double values as parameters and returns the smallest value of the three. Here is a sample call to this method. This sample call would appear in the main() method:

System.out.println( smallest (3.5, 6.7, -8.5) ); # prints -8.5

2) largest()

This method takes three double values as parameters and returns the largest value of the three. Here is a sample call to this method, which would appear in the main() method: System.out.println( largest (3.5, 6.7, -8.5) ); # prints 6.7

3) average()

This method takes three double values as parameters and returns the average of the three. Here is a sample call to this method, which would appear in the main() method: System.out.println( average (3.5, 6.7, -8.5) ); # prints .57

4) allTheSame()

This method returns True if all three double values sent in as parameters are of equal value, and returns False if at least one of the three double values is different from the other two. Here is a sample call to this method, which would appear in the main() method:

System.out.println( allTheSame (3.5, 6.7, -8.5) ); # prints False

5) allDifferent()

This method returns True if all three double values sent in as parameters have the same value, and returns False if at least two of the three doubles are of equal value. Here is a sample call to this method, which would appear in the main() method:

System.out.println( allDifferent (3.5, 6.7, -8.5) ); # prints True

Note that I only showed you one sample method call for each of the five methods above. You will need to test your method definitions by calling them each many times with many different values for the parameters. For example, just because the method allDifferent() can detect when the parameters are all different values does not mean that your method definition can detect when the parameters are all the same value; in that case it needs to return False.

HINT: You will save a LOT of time if you write and test one method definition at a time. Do not begin thinking about the next method definition until you have thoroughly tested the previous one and found it to work perfectly.

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

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions

Question

=+write, or speak a foreign language?

Answered: 1 week ago

Question

What is the Financial Trend Monitoring System and how is it used?

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago