?

AP® Computer Science Principles

Free Version

Upgrade subject to access all content

Difficult

Calculating Hours and Minutes

APCSP-Q1PV4G

A program reports the number of hours and minutes that have passed given a total number of minutes. For example, consider the following user input:

totalMin: 85

The following would be output:

1 hour and 25 minutes have passed.

Which of the following code segments would assign the correct values to the hour and minutes variables?

A

hour ← totalMin / 60
minutes ← totalMin MOD 60

B

minutes ← totalMin MOD 60
hour ← (totalMin - minutes) / 60

C

minutes ← totalMin MOD 60
hour ← totalMin / 60

D

hour ← totalMin / 60
minutes ← totalMin /60