The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

funkyhamster (1) [Avatar] Offline
Section 2.7 suggests an exercise:
"Write a program to determine how fast their ship would need to travel (km/h) in order to reach Malacandra in 28 days. Assume a distance of 56,000,000 km."

But the answer is never provided anywhere.

Quick Check 2.8
"The distance between Earth and Mars varies from nearby to opposite sides of the sun. Write a program that generates a random distance from 56,000,000 to 401,000,000 km."

The answer given is:
var distance = rand.Intn(346000000) + 56000000

Shouldn't it be:
var distance = rand.Intn(345000001) + 56000000
Nathan Youngman (56) [Avatar] Offline

A solution to the Try This in chapter 2 is at the back of the book in Appendix A. This is mentioned in the Try This section of chapter 1, but not repeated in chapter 2.

Compare your solution to the code listing in Appendix A.

Thank you for reporting the error in the solution to quick check 2.8. You are correct, and I am updating it in the manuscript.

Nathan Youngman (56) [Avatar] Offline
Sorry, that change didn't make it into MEAP v13, but it is fixed in the manuscript source files.