Computers and Technology

(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)

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 16:30, nxusasmangaliso1191
The most common battery cable terminal is a that provides a large surface contact area with the ability to tighten the terminal onto the battery post using a nut and bolt.
Answers: 2
image
Computers and Technology, 22.06.2019 18:40, penelopymorales24
Mariah was working on a multimedia presentation that included both video and audio files. the file was huge, and she wanted to send it to her coworker in another office. she needed to reduce the size of the file so that it could be transmitted faster. the utility she used to do this was
Answers: 2
image
Computers and Technology, 23.06.2019 04:10, cvbnkifdfg
2pointswho was mikhail gorbachev? oa. a russian leader who opposed a coupob. a polish leader who founded the labor union "solidarityoc. a soviet leader who called for a closer relationship with the unitedstates, economic reform, and a more open societyd. a soviet leader who called for more oppression in the soviet union
Answers: 3
image
Computers and Technology, 24.06.2019 00:30, lovemusic4
Setting up a home network using wireless connections is creating a a. vpn b. lan c. wan d. mini-internet
Answers: 2
Do you know the correct answer?
(c) The method propLong(int n) returns the proportion of long hailstone sequences with starting valu...

Questions in other subjects:

Konu
Social Studies, 24.08.2019 20:10
Konu
Mathematics, 24.08.2019 20:10