0

Quiz 1 session2

How to code this quetion? Countdown New Year's Eve is still 2 months away, but as the one appointed to run the countdown, Bibi wants to finish the task as soon as possible. Bibi wants to make a program to count down from N to 1. To make it more interesting, she replaces some special numbers with “X SECONDS TILL NEW YEAR!!”. The special numbers are 5, 10, 30, 60, and the starting number. Help Bibi to make the program. Format Input The first line will be an integer T, the number of test cases. Each test case will contain an integer N, the starting number. Format Output Print “Case #X:” on the first line of each test case. Then print the countdown each on their own line. Constraints 1 <= T <= 10 1 <= N <= 10000 Sample Input Sample Output 2 10 4 Case #1: 10 SECONDS TILL NEW YEAR!! 9 8 7 6 5 SECONDS TILL NEW YEAR!! 4 3 2 1 Case #2: 4 SECONDS TILL NEW YEAR!! 3 2 1

10th Oct 2018, 3:22 AM
Yohan Bastian
Yohan Bastian - avatar
1 Antwort
0
There are a few different ways. You have three major tasks: reading T & the various Ns, making the special messages, or the count down loop. Code and test them by themselves in any order. Once you got them working, put them together to complete your program. Note: you would create constants to drive the second or third tasks and put printouts of T and Ns to prove the first task works. You could also break things down even futher as the smaller your code the easier it is to test.
10th Oct 2018, 7:19 AM
John Wells
John Wells - avatar