Share your repls and programming experiences

← Back to all posts
Speed Find
TylerFlowers (4)

Calculates the remaining time from the speed and remaining value.

Yes, it's a fairly simple program, but I'd figure I might as well share it. It's useful if you have something like a mining program, as most of them don't tell you how much time is remaining until you get a certain amount of currency (mostly because it's impossible when there are multiple rewards.) You can also use it to determine how long a plane or train trip will last for.

Just keep in mind that the speed is by seconds, not hours. That means you have to convert MPH to MPS by doing this: MPH / 60 / 60 = MPS
Update: You no longer have to do the above. Just set your time unit when asked to.

Commentshotnewtop
Nanashi (7)

By the way... For example, 100 km / 10 km/h = 10 h and 100 km / 10 km/s = 10 s. As long as distance and speed uses the same distance unit, time remaining is just the time unit used for speed.

Having to google [value of something/hour] * 60 * 60 beforehand for meaningful time remaining feels iffy. Perhaps ask what time unit the user is using, then go from there:

Enter a rate (number only) e.g. miles per hour:
Enter how much is left to finish e.g. miles:
Time remaining is [result] units of time.
Enter time unit used if you would like to see more units:
0 or nothing) Skip
1) Second
2) Minute
3) Hour
4) Day
[...]
TylerFlowers (4)

@Nanashi Good idea, I'll update when I can.
Edit: Done. Not exactly what you put up, but somewhat like that. I wasn't able to separate the units for some reason so I just had it set to both.