subject

Assume that the classes listed in the Java Quick Reference have been imported where appropriate. Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied.
In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods will not receive full credit.

4. The NumberProperties class contains methods used to determine various properties of numbers. You will write one method of the NumberProperties class.

public class NumberProperties
{
/** Returns true if num is a perfect square and false otherwise */
private static boolean isSquare(int num)
{ /* implementation not shown */ }

/** Returns true if num is a perfect cube and false otherwise */
private static boolean isCube(int num)
{ /* implementation not shown */ }

/** Returns the ratio of the sum of all the perfect cubes between start and end,
* inclusive, to the sum of all the perfect squares between start and end, inclusive,
* as described in part (a)
* Precondition: 1 <= start <= end <= Integer. MAX_VALUE
* There is at least one perfect square between start and end,
* inclusive.
*/
public static double (int start, int end)
{ /* to be implemented in part (a) */ }

// There may be variables and methods that are not shown.
}
(a) Write the method , which returns the ratio of the sum of all perfect cubes between start and end, inclusive, to the sum of all perfect squares between start and end, inclusive.

Two helper methods, isSquare and isCube, have been provided. The isSquare method returns true if its parameter is a perfect square and returns false otherwise. The isCube method returns true if its parameter is a perfect cube and returns false otherwise.

For example, of the numbers between 5
and 30
, inclusive, two are perfect cubes ( 8
and 27
) and three are perfect squares ( 9
, 16
, and 25
). The sum of the two perfect cubes is 35
and the sum of the three perfect squares is 50
. The method call NumberProperties.(5, 30) returns the ratio of the sums 35 and 50, which is 0.7.

You must use isSquare and isCube appropriately to receive full credit. Assume that there is at least one perfect square between start and end, inclusive.

Complete method .

/** Returns the ratio of the sum of all the perfect cubes between start and end, inclusive,
* to the sum of all the perfect squares between start and end, inclusive,
* as described in part (a)
* Precondition: 1 <= start <= end <= Integer. MAX_VALUE
* There is at least one perfect square between start and end, inclusive.
*/
public static double (int start, int end)
BoldItalicUnderline

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:30
Aconstruction company is creating a powerpoint presentation describing how they calculate costs during each construction step. they plan to email this presentation to clients. the individual clients will be watching the presentation slide show on their own personal computers. what is the most important formatting step the company should take to make the text readable and pleasing to the eye?
Answers: 2
question
Computers and Technology, 22.06.2019 19:30
Avariable definition defines the name of a variable that will be used in a program, as well as
Answers: 3
question
Computers and Technology, 23.06.2019 00:30
Pl i need the answer now ! which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
question
Computers and Technology, 23.06.2019 03:00
What are the different parts of computer
Answers: 2
You know the right answer?
Assume that the classes listed in the Java Quick Reference have been imported where appropriate. Un...
Questions
question
Social Studies, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
Mathematics, 11.09.2020 07:01
question
English, 11.09.2020 07:01
question
English, 11.09.2020 08:01
Questions on the website: 13722367