|
-
March 16th, 2011, 12:47 PM
#1
Help - Program without use of Date/Time Function
- You are supplied with a date which should be in the form day in the month (1 to 31), month (1 to 12), year (1760 onwards)
- check the validity of the date (above limits are observed, day number is valid for the month – i.e 31, 6 is not valid as there are only 30 days in June)
- check for leap years; a leap year occurs when the year is divisible either by 400, or by 4 but not 100
- produce a string with the day within the month followed by “st”, “nd”, “rd” or “th” as appropriate, followed by the full month name, followed by a comma and then the year. So 22, 1, 1944 should produce the string:
22nd January, 1944
Firstly to be absolutely clear, I can NOT rely on methods provided by the C# environment, so DateTime is out of the question.
I am relatively new to programming and have recently been set a series of challenges by my tutor. I have been able to tackle most successful all be it with a bit of help here and there, but I am becoming increasingly frustrated by this question. I have figured out the formulae to calculate leap years, but I am struggling to attain the requirements in regards to the user input and output. It has been suggested to me by a friend that I use either a substring or split string in regards to attaining date input in the format of dd/mm/yyyy. However, I have no experience of using either function and am looking for some advice as to which would be more appropriate and perhaps easier to implement in this circumstance. I am also at a loss as to output the date as the specification states with the month name and st, nd etc. after the day.
I imagine that this more than likely seems like a noobish problem that most adequate programmers would tackle and solve without much trouble, but I am becoming desperate. Any pointers in the right direction would be greatly appreciated.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|