write a program to prompt the user for 2 dates consisting of a month and a year and display the number of years and months between these 2 dates the two dates don t have to be in order

To calculate a positive year difference and the corresponding month difference, a. Subtract the earlier year from the later year to get the year difference. b. Subtract the month associated with the earlier year from the month associated with the later year. The month difference can be negative (see examples in the table below). In sample 2, the month difference is negative. The difference, 3 years and -2 months, means it would be 3-year difference if this were 2 months later. A date difference should not contain a negative month difference. A negative can be adjusted by regrouping one-year difference into 12-month difference. 2. To calculate a date difference between two dates that are in the same year, the year difference is always zero. The month difference should be calculated as a non-negative value.

details is at part IV in the file I upload

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *