subject

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
public void updateAge(int extraMonths)
{
/* body of updateAge */
}
Which of the following code segments shown below could be used to replace /* body of updateAge */ so that the method will work as intended?
I int yrs = extraMonths % 12;
int mos = extraMonths / 12;
years = years + yrs;
months = 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. I and II only
e. II and III

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 16:30
Which of the following statements best describes it careers?
Answers: 2
question
Computers and Technology, 23.06.2019 09:30
:you areto design the controller for alight that functions both as an ordinary light and also as a motion activated light and alarm. a.if the manual switch s is on, then the light l is on. b.besides the manual switch, there is a motion detector, m1, which activatesthis light.c.if motion is detected but the light is on anyway because s is on, only then a secondoutput a, an alarm, is turned on. d.the disable switch, d, disables the motion activated light and alarmbut leaves manual control operation of the light using switch s.(i)read the problem statement and clearly identify the inputs and outputs for the circuit you are designing. (ii)create the truth table for this system; include the light, alarm, switch, disable, and the motion sensor.(iii)draw a schematic of this system.
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
Which of these is an example of an integrated presentation? a. a table created in powerpoint b. an image pasted into powerpoint c. a caption created in powerpoint d. an excel chart pasted into powerpoint
Answers: 1
question
Computers and Technology, 23.06.2019 13:10
What is domain name system (dns)? allows dynamic ip address allocation so users do not have to have a preconfigured ip address to use the network converts ip addresses into domains, or identifying labels that use a variety of recognizable naming conventions the efficient coexistence of telephone, video, and data communication within a single network, offering convenience and flexibility not possible with separate infrastructures the integration of communication channels into a single service
Answers: 2
You know the right answer?
Consider the following instance variables and incomplete method that are part of a class that repres...
Questions
question
Mathematics, 12.07.2021 22:20
question
Business, 12.07.2021 22:20
Questions on the website: 13722362