Click here to Skip to main content
15,903,523 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The person inputs their DOB. Output what day their next birthday will be on. Then create a table of the days their birthday has fallen on and the number of times it has done so. I need some help on what to do next.

What I have tried:

Dim dob As Date
Dim beginYear As Integer
Dim rightNow As Date
rightNow = Date.Now
rightNow = rightNow.ToShortDateString
Console.WriteLine("When is your birthday?")
dob = Console.ReadLine()
dob = dob.ToShortDateString
beginYear = DateDiff(DateInterval.Month, birthday, rightNow)
Console.WriteLine(beginYear & " months.")
Console.ReadLine()
Posted
Updated 3-Sep-18 22:16pm

1 solution

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think! Start by looking at the question as four different parts:
1) Get the DOB from the user, check it's a valid date, and convert it to a DateTime variable.
2) When that works, find out what day of the week it is - that's simple, the DateTime struct will tell you that.
3) Then look at next year - that's also easy, DateTime has an AddYear method.
4) Then create your table - just a combination of steps 2 and 3 repeated back to age 1, and storing the counts in an array of seven elements where each element counts a specific day of the week.

It's not complicated, if you break it up like that and think about it for a moment. Do one bit, test it, fix it, and move on to the next when you have it working, not before.

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
 
Share this answer
 
Comments
SpongeBobHere 4-Sep-18 5:51am    
Thanks! Sorry - i didnt mean for it to say do it...i just wanted some tips on where to go next. i will try what you said- thanks
OriginalGriff 4-Sep-18 6:53am    
You're welcome!
OriginalGriff 4-Sep-18 12:28pm    
DateTime.TryParse or DateTime.TryParseExact are better.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900