
EXERCISES
Putting debugging exercises in a book can be a bit strange. If the book includes
the code, you can stare at it until you see the bugs without using the debugger,
and that would defeat the purpose.
For that reason, this section only describes the programs containing the bugs
and you’ll have to download the broken programs from the book’s web site
at
www.wrox.com or www.CSharpHelper.com/24hour.html. You can find the
programs and corrected versions in the Lesson12 folder. The corrected versions
are named after their exercises, for example, Ex12-1Solution. Modified lines are
marked with comments.
1. Debug the CelsiusToFahrenheit program shown in
Figure 12-7. (Hint: 0 Celsius = 32 Fahrenheit and
100 Celsius = 212 Fahrenheit.)
2. Debug the FeetToMiles program shown in Figure 12-8.
(After you fix this one, notice that using constants instead of
magic numbers and the approach taken by Exercises 5 and 6
in Lesson 11 would make fixing these bugs easier and might
have avoided them from the start. Also note again that the
duplicated code is a bad thing that you’ll learn how to fix in
Lesson 20.)
3. The ResizePicture program is supposed to zoom in on a picture
when you adjust its
TrackBar. Unfortunately when you move
the
TrackBar, the picture seems to shrink and move to a new
location. Debug the program.
4. Debug the TaxForm program, which performs a fictitious tax calculation ...