Take a single number of seconds and break it into hours, minutes, and seconds.
Activity 1.6's adventurer problem split a number once. This splits it twice, and the leftover from the first split becomes the input to the second. That chaining is the whole challenge.
There are 3600 seconds in an hour, so the obvious first move is to divide — and to get a real answer instead of a truncated one, you have to write it the way Activity 1.6 taught, with a .0 to force real division. Here is what that gives you:
double hours = totalSeconds / 3600.0;Console.WriteLine(hours);2.573611111111111Two point five seven hours is a correct answer to a different question. You need 2 hours and then you need to know what is left over, because that leftover is what becomes minutes.
Activity 1.6 gave you both halves of that: % gives the leftover, and subtracting the leftover before dividing gives the whole number.
int totalSeconds = 9265;
// Your code goes below this line.Run your program again with each of these values:
7200 — should be exactly 2 hours, 0 minutes, 0 seconds59 — should be 0 hours, 0 minutes, 59 seconds3661 — work out by hand what this should be, then checkAll three must come out right. A program that works on 9265 and fails on 59 is a program that got lucky.
Total seconds: 9265
2 hours, 34 minutes, 25 secondsSubmit your program file, plus:
3661 should have been, worked out by hand, written down before you ran itPredicting the answer first is not busywork. On the exam you will trace code with no way to run it, and this is that skill at its smallest.