### Question:
TSAGeoMag { public double decimalYear(GregorianCalendar cal) { int year = cal.get(Calendar.YEAR); double daysInYear; if(cal.isLeapYear(year)) { daysInYear = 366.0; } else { daysInYear = 365.0; } return year + cal.get(Calendar.DAY_OF_YEAR)/daysInYear; } TSAGeoMag(); double getDeclination( double dlat, double dlong ); double getDeclination( double dlat, double dlong, double year, double altitude ); double getIntensity( double dlat, double dlong ); double getIntensity( double dlat, double dlong, double year, double altitude ); double getHorizontalIntensity( double dlat, double dlong ); double getHorizontalIntensity( double dlat, double dlong, double year, double altitude ); double getVerticalIntensity( double dlat, double dlong ); double getVerticalIntensity( double dlat, double dlong, double year, double altitude ); double getNorthIntensity( double dlat, double dlong ); double getNorthIntensity( double dlat, double dlong, double year, double altitude ); double getEastIntensity( double dlat, double dlong ); double getEastIntensity( double dlat, double dlong, double year, double altitude ); double getDipAngle( double dlat, double dlong ); double getDipAngle( double dlat, double dlong, double year, double altitude ); double decimalYear(GregorianCalendar cal);  }### Answer:
@Test public final void decimalYear() { TSAGeoMag mag = new TSAGeoMag(); GregorianCalendar cal = new GregorianCalendar(2010, 0, 0); assertEquals(2010.0, mag.decimalYear(cal), 0.0); GregorianCalendar cal2 = new GregorianCalendar(2012, 6, 1); assertTrue(cal2.isLeapYear(2012)); assertEquals(2012.5, mag.decimalYear(cal2), 0.0); cal2 = new GregorianCalendar(2013, 3, 13); assertFalse(cal2.isLeapYear(2013)); assertEquals(2013.282, mag.decimalYear(cal2), 0.0005); }