![]() |
![]() |
Time Segments Computer Programming ProblemProblem DescriptionCreate an application that correctly calculates time segments. A segment of time can be represented as a number of days (d), a number of hours (h), a number of minutes (m) and a number of seconds (s). For example, a valid time segment would be: 12 days, 6 hours, 5 minutes and 49 seconds. Valid output values for each component of time are as follows:
The input values for the time segments will not conform to the above rules. The application must determine invalid values and convert them to valid values. For example the time segment below: 23 30 45 93 would indicate days = 23, hours = 30, minutes = 45, and seconds = 93. The equivalent valid time segment would be: 24 days, 6 hours, 46 minutes, and 33 seconds. This is based on 93 seconds being converted to 1 minute and 33 seconds. The one minute is added to the input value of 45 resulting in 46 minutes. The input value of 30 hours is converted to one day (24 hours) and 6 hours. The one day is added to the input value of 23 resulting in 24 days. Consider a second example below: 0 105 99 120 would indicate 0 days, 105 hours, 99 minutes, and 120 seconds. The equivalent valid time segment would be: 4 days, 10 hours, 41 minutes. This based on the 120 seconds being converted to 2 minutes and the 105 days being converted to 4 days and 10 hours. Note there is no time segment for seconds because that would be 0. Omit any time segment if it would be zero. There are 60 seconds in a minute, 60 minutes in a hour, and 24 hours in a day. Input/OutputInput to this application will be a series of four integer values representing in order the d, h, m, and s as described above. However the input values for d, h, m, and s can be any integer value equal to or greater than zero. You do not need to edit to ensure only numbers are entered. Only positive integer numbers will be entered. The output will be a valid time segment in the format: a days, b hours, c minutes, and d seconds. Omit any time segment if it would be zero. Your values may be input as a single set of data or as a grouping of four individual pieces of data. Your application can be created to process a single set of data. That is, after processing a set of data, your application can end. You can then start the application again and enter a second set of data. If you use a graphical interface (Visual Basic, C#, ...) you can enter the data in text boxes and display the results in text boxes or labels. However, a graphical interface is not required for this application. If you create a command line application you can prompt for the input numbers one at a time or enter them all in a single input statement. Sample Input/OutputYour application must provide the following results for the given input. Your output must be formatted as indicated in the Output column below.
|
Want more information?Melinda White Get Admissions Info Did you know? |
| Altamonte Springs Campus 850 South State Road 434 Altamonte Springs, FL 32714 | Heathrow Campus 1055 AAA Drive Heathrow, FL 32746 | Oviedo Campus 2505 Lockwood Boulevard Oviedo, FL 32765 | Sanford/Lake Mary Campus 100 Weldon Boulevard Sanford, FL 32773 |
| A Diverse Learning Community...An Equal Access/Equal Opportunity College © Seminole Community College, 1996-2008 Privacy Policy About Us | Contact Us | Site Map | |||