Question: Find and fix the bugs in the following C# program. using System; /* Many businesses need to determine the amount of time that has passed

Find and fix the bugs in the following C# program.

using System; /* Many businesses need to determine the amount of time that has passed between events. These durations are measured in elapsed seconds, and the values can be large. However, humans cannot easily understand times in these units. Conversion between seconds and the more standard hours, minutes, and seconds is therefore necessary. Assume that a previous programmer wrote this code, but before debugging and delivering it, was transferred to a new department. Your task to finish the work. The code is almost correct, but compilation (syntax), coding (specification), or output (semantic) bugs exist. Carefully study the code, determine the problem, and fix the bug or bugs so that the output is as expected. Change as little code as possible to correct the problem. Place a comment on or before the fixed lines explaining what is wrong and how the fix resolves the issue--no comment(s), no points. */ namespace FFTB04 { class driver { static void Compute(int duration, out int hours, out int minutes, out int seconds) { hours = duration % 60 * 60; // how many hours? duration -= hours * 60 * 60; // subtract the hours minutes = duration % 60; // how many minutes? duration -= duration * 60; // subtract the minutes seconds = duration; } static void Main(string[] args) { int duration = 12345; // in seconds int seconds; int minutes; int hours; Console.WriteLine("12345 seconds is 3 hours, 25 minutes, and 45 seconds"); Compute(duration, out hours, out minutes, out seconds); Console.WriteLine("{0} seconds is {1} hours, {2} minutes, and {3} seconds", duration, hours, minutes, seconds); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!