Programming In Java

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.

Thousands of Zune players locked up at the very end of 2008, which was a leap year. (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? Fix the code to always return the correct date.

Don't use plagiarized sources. Get Your Custom Essay on
Programming In Java
Just from $13/Page
Order Essay

RevertType your solution here:1int days = getTotalDaysSince1980();2int year = 1980;3while (days > 365) { // subtract out years4 if (isLeapYear(year)) {5 if (days > 366) {6 days -= 366;7 year += 1;8 }9 } else {10 days -= 365;11 year += 1;12 }13} Indent
Sound F/X
HighlightingThis is a method problem. Write a Java method as described. Do not write a complete program or class; just the method(s) above.

Place Order
Grab A 14% Discount on This Paper
Pages (550 words)
Approximate price: -
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)