The following code is a slightly modified version of actual code that was in the Microsoft Zune

Question:

The following code is a slightly modified version of actual code that was in the Microsoft Zune music player in 2008. The code attempts to calculate today’s date by determining how many years and days have passed since 1980. Assume the existence of methods for getting the total number of days since 1980 and for determining whether a given year is a leap year:

int days getTotalDaysSince1980 () ; year 1980; while (days > 365) { // subtract out years if (isLeapYear (year)) { if (days > 366) { days 366; year += 1; } } else { days 365; year += l; } }

Thousands of Zune players locked up on January 1, 2009, the first day after the end of a leap year since the Zune was released. (Microsoft quickly released a patch to fix the problem.) What is the problem with the preceding code, and in what cases will it exhibit incorrect behavior? How can it be fixed?

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: