funkyhamster (1) [Avatar] Offline
#1
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
fmt.Println(distance)


Shouldn't it be:
var distance = rand.Intn(345000001) + 56000000
fmt.Println(distance)
Nathan Youngman (47) [Avatar] Offline
#2
Hi,

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.
Nathan Youngman (47) [Avatar] Offline
#3
Sorry, that change didn't make it into MEAP v13, but it is fixed in the manuscript source files.