subject

(c) The method propLong(int n) returns the proportion of long hailstone sequences with starting values between 1 and n, inclusive. Consider the following table, which provides data about the hailstone sequences with starting values between 1 and 10, inclusive.

Starting
Value Terms in the Sequence Length of the
Sequence Long?
1 1 1 No
2 2, 1 2 No
3 3, 10, 5, 16, 8, 4, 2, 1 8 Yes
4 4, 2, 1 3 No
5 5, 16, 8, 4, 2, 1 6 Yes
6 6, 3, 10, 5, 16, 8, 4, 2, 1 9 Yes
7 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 17 Yes
8 8, 4, 2, 1 4 No
9 9, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1 20 Yes
10 10, 5, 16, 8, 4, 2, 1 7 No

The method call Hailstone. propLong(10) returns 0.5, since 5 of the 10 hailstone sequences shown in the table are considered long.

Write the propLong method. Assume that hailstoneLength and isLongSeq work as intended, regardless of what you wrote in parts (a) and (b). You must use isLongSeq appropriately to receive full credit.

/** Returns the proportion of the first n hailstone sequences that are considered long,

* as described in part (c).

* Precondition: n > 0

*/

public static double propLong(int n)

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 09:30
What are the steps involved in accepting all the changes in a document? arrange these in order click edit. click accept or reject. click changes. click accept all.
Answers: 1
question
Computers and Technology, 22.06.2019 22:40
In this lab, you complete a python program that calculates an employee's annual bonus. input is an employee's first name, last name, salary, and numeric performance rating. if the rating is 1, 2, or 3, the bonus rate used is .25, .15, or .1 respectively. if the rating is 4 or higher, the rate is 0. the employee bonus is calculated by multiplying the bonus rate by the annual salary.
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a,b] se pot scrie ca produs de două numere prime? “.
Answers: 1
question
Computers and Technology, 23.06.2019 21:30
Enzo’s balance sheet for the month of july is shown. enzo’s balance sheet (july 2013) assets liabilities cash $600 credit card $4,000 investments $500 student loan $2,500 house $120,000 mortgage $80,000 car $6,000 car loan $2,000 total $127,100 total $88,500 which expression finds enzo’s net worth?
Answers: 1
You know the right answer?
(c) The method propLong(int n) returns the proportion of long hailstone sequences with starting valu...
Questions
question
Social Studies, 21.08.2019 23:50
Questions on the website: 13722361