I'm just working on a personal project with calculating time/speed/distance. I've encountered a problem with my program though, when I input say 36 for kms to cover and 100 km/h as speed, the program which should give me back a result such as 21.6 minutes but instead it gives me 0 minutes.
However when I input 36.0 and 100, the program works perfectly to what I want. Why is it when I've inputted a decimal for my kms to cover it works fine yet when an integer is input it will not calculate properly.
Interested to see what the problem could be, is it the order of my code? Perhaps, making the variable a float or some such thing could be the fix? Not sure what the issue is since it occurs on such a specific thing such as ensuring the number is a decimal. Still learning Python as you can probably tell from my code.
Thanks in advance for your assistance.
Code is as follows;
print('Welcome to my calculator')
d = float(input('How many kms do you want to cover? '))
s = float(input('How fast will you be travelling (km/h)? '))
t = d/s
if t < 1:
t = t * 60
print('You will reach your destination in ') + str(t) + (' minutes.')
else:
print('You will reach your destination in ') + str(t) + (' hours.')