By Developers, For Developers

Historical errata for Exercises for Programmers

PDF PgPaper PgTypeDescriptionFixed onComments
51ERROR

The following constraint is listed:

“Use a function called calculateMonthsUntilPaidOff which accepts the balance, the APR, and the number of months as its arguments, and returns the number of months. Do not access any of these values outside of the function.”

The “number of months” is listed as both an argument and the return value. The arguments are actually balance, apr, and monthly payment, and the return value is number of months.

“Use a function called calculateMonthsUntilPaidOff which accepts the balance, the APR, and the monthly payment as its arguments, and returns the number of months.”

2015-08-08
51ERROR

The formula lists the variable ‘n’, but below it is referenced as a capital N: ‘N is the number of months’. It would be more clear if it was consistently cased.

2015-08-08
51ERROR

I tried solving the Months to Pay Off Credit Card exercise, and I kept getting a different answer than in the book. The book says with arguments balance = 5000, apr = 12, and monthly payment = 50, the answer should be 70 months. But my output is 478 months. I decided to use an alternate calculator on the internet to check my work, and the result agreed with my output. So I think the example in your book is incorrect. Given arguments 5000, 12, and 50, the answer is not 70 months.

Here’s the calculator I used:
www.bankrate.com/calculators/credit-cards/credit-card-minimum-payment.aspx

If you enter Credit card balance $5,000.00, Credit card rate: 12, and minimum payment: 1, then it chooses $50.00 as the monthly payment, and claims that it will take 30+ years to pay off.

2015-08-08Yup it's a typo in the example. It should be $100 per month, not $50. $ 50 is not enough to cover the interest accrued. :)
9TYPO

finally, thank you Ana for being awesome, and thank you Lisa for all the hugs and text messages while I was writing.


“Finally” should be capitalized.

2015-08-08
21TYPO

Display “Tip: $” + tip"
Display “Total: $” + total"


There are three double quotes per line.

2015-08-08
2TYPO

If you’re ready to open your text editor and hammer out the code, you’re jumping way too ahead of yourself.

Should read:

If you’re ready to open your text editor and hammer out the code, you’re jumping way too far ahead of yourself.

Or:

If you’re ready to open your text editor and hammer out the code, you’re jumping way ahead of yourself.

2015-08-14
61SUGGEST

I suggest to have the multiplication table generated starting from 1. having a column and row with zeros is not very interesting. At least I do that with my compile-time C template metaprogramming example.

2015-08-14I prefer to keep it as-is, since that's what multiplication tables look like.
79ERROR

The program requirement states you should prompt for ‘the number of slices per pizza’. However, this is missing from the example output.

How many people? 8
How many pizzas do you have? 2
<= missing slices here

80ERROR

Variant Challenge needs to include pizza slices

The last challenge is to ‘Create a variant of the program that prompts for the number of people and the number of pieces each person wants, and calculate how many full pizzas you need to purchase’. However, you could not calculate this without knowing the number of slices in a pizza.

22TYPO

The description for exercise #8 (pizza party) says to “Write a program to evenly divide pizzas. Prompt for the number of people, the number of pizzas, and the number of slices per pizza.” In the example output there is no prompt for the number of slices per pizza. Here’s a screen shot:

/var/folders/yj/1j38b5h53jx9p2gkhl7_r5kc0000gq/T/com.skitch.skitch/DMD8ABB07BC-0AD7-4E20-AE6D-9A2DEF0BED31/exercises-for-programmers_p1_0_pdf_page_36_of_114.png

68ERROR

I may be wrong but the std deviation is not 400.25, but instead 353.55. Sorry if I am
wrong :)

89TYPO

The example output is not sorted correctly. J comes before L.

39ERROR

This isn’t a showstopper. I’m working around it myself, it’s just a bit inconsistent in the book. The book is awesome, btw.

20 - Multistate Tax Calculator:

The problem statement suggests Wisconsin residents should be charged an amount of tax, plus an additional levy based on their county of residence.

The problem statement doesn’t give the amount of tax for Wisconsin residents, at the state level.

The problem statement also asks for Wisconsin residents to be prompted for their county of residence. The Example Output shows:

“What state do you live in? Wisconsin”
“The tax is $0.50.”

The prompt for the county of residence is missing. I’m working around it by adding:

“What state do you live in? Wisconsin”
“What county do you live in? Eau Claire”
“The state tax is $0.55.” (Inferred from previous exercise where the rate is 5.5%)
“The county tax is $0.05.”
“The total tax is $0.60”
“The total is $10.60”

68TYPO

The standard deviation of the numbers 100, 200, 1000 and 300 is either 353.55 or 408.25 depending on whether we are talking about a sample or a population. I assume that the answer given in the book of 400.25 is a typo of 408.25, but in that case the text should instruct the reader to subtract one from the number of elements when calculating the mean otherwise they will get 353.55

4950TYPO

The formula for calculating the Months to Pay, I had to remove the log from the upper part of the division, without removing it, the log will be a negative number, which is not possible programme wise

54ERROR

ch6 Repetition:
code
Go: for counter <= 1 -> for counter >= 1
JavaScript: for(…; counter <= 1; …) -> for(…; counter >= 1; …

5ERROR

Wrong use of the term test plan.
Should be: test case

Also observed on pages 6,9,19,29

Refer e.g. to the ISTQB Glossary definitions (based on ISO 29119):
A test plan is “Documentation describing the test objectives to be achieved and the means and the schedule for achieving them, organized to coordinate testing activities.”
A test case is “A set of preconditions, inputs, actions (where applicable), expected results and postconditions, developed based on test conditions.”

36TYPO

In example output :

Example Output
How many people? 8
How many pizzas do you have? 2
8 people with 2 pizzas
Each person gets 2 pieces of pizza.
There are 0 leftover pieces.

Query for “How slices per pizza? ” is missing ?

According to exercise, it should query for 3 inputs ?

Thanks,
Regards,

57%ERROR

in Exercise 26 the formula looks wrong because logs can not be applied to a negative numbers.

36SUGGEST

The second paragraph indicates the user is prompted for, “the number of slices per pizza”, however this prompt is not included in the example output section. To avoid confusion, I suggest adding this additional prompt to the third line of the “Example Output” section. E.g.

How many people? 8
How many pizzas do you have? 2
How many slices per pizza? 8

Categories: