Thread: Ex 15-2
View Single Post
  #3 (permalink)  
Old July 28th, 2011, 09:33 AM
Rod Stephens's Avatar
Rod Stephens Rod Stephens is offline
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

A good question! Here's what I would do:

1. Get a birth date. Have the user enter a date in a TextBox and click a Go button.

2. Parse the date to create a Date variable. Use its Year, Month, and Day properties to get its year month and day.

3. Clear the ListBox. Then for (int i = 0; i <= 10; i++):

a. Create a new Date variable using the Year + i, Month, and Day.

b. Display the new Date and its DayOfWeek.ToString() in the ListBox.

I think you can do everything here except the loop with what you know by Lesson 15. Loops are covered in Lesson 19. (I suppose you could do this with a series of 11 nearly identical statements instead of using a loop but it would be poor code.)

Give that a try and let me know if you get stuck. If you want to see an example, email me and I'll send one to you.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)