I'm doing C programming exercise for college, and couldn't figure out how to calculate the following value based on four values (2 of each from one type of variable). The exercise is to write a program for a progress bar for downloading a file.
- time: the current time
- startTime: the download start time
- bytes: the number of bytes downloaded
- totalBytes: the total file size in bytes
The program needs to calculate the Elapsed_Time, Percent_Completed, Download_Speed, Total_Time and Remaining_Time.
I can't figure out the formula for Total_Time. That is the estimated total time to download the file.
I used this, but didn't work:
(time - startTime) / (totalBytes - bytes)
Any help is appreciated. Cheers