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 06:30
Plz 40 points what are raster vectors? a bitmap image a vector file a type of printing press a small projector
Answers: 1
question
Computers and Technology, 23.06.2019 10:50
The volume v and paper surface area a of a conical paper cup are given by where r is the radius of the base of the cone and h is the height of the cone. a. by eliminating h, obtain the expression for a as a function of r and v. b. create a user-de ned function that accepts r as the only argument and computes a for a given value of v. declare v to be global within the function. c. for v ! 10 in.3 , use the function with the fminbnd function to compute the value of r that minimizes the area a. what is the corresponding value of the height h? investigate the sensitivity of the solution by plotting v versus r. how much can r vary about its optimal value before the area increases 10 percent above its minimum value?
Answers: 1
question
Computers and Technology, 23.06.2019 23:30
Worth 50 points answer them bc i am not sure if i am wrong
Answers: 1
question
Computers and Technology, 24.06.2019 00:20
Describe a data structures that supports the stack push and pop operations and a third operation findmin, which returns the smallest element in the data structure, all in o(1) worst-case time.
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
Physics, 26.08.2021 01:00
question
History, 26.08.2021 01:00
question
Mathematics, 26.08.2021 01:00
question
French, 26.08.2021 01:00
question
Spanish, 26.08.2021 01:10
Questions on the website: 13722363