Consider the following instance variables and incomplete method that are part of a class that represents an item. The variables years and months are used to represent the age of the item, and the value for months is always between 0 and 11, inclusive. Method updateAge is used to update these variables based on the parameter extraMonths that represents the number of months to be added to the age.
private int years;
private int months; // 0 <= months <= 11
// precondition: extraMonths >= 0
public void updateAge(int extraMonths)
{
/* body of updateAge */
}
I)
int yrs = extraMonths % 12;
int mos = extraMonths / 12;
years = years + yrs;
month = months + mos;
II)
int totalMonths = years * 12 + months + extraMonths;
years = totalMonths / 12;
months = totalMonths % 12;
III)
int totalMonths = months + extraMonths;
years = years + totalMonths / 12;
months = totalMonths % 12;
A) I only
B) II only
C) III only
D) II and III only
E) I, II, and III