int velMperMin = 667;
int distM = 70;
double movT = (distM/velMperMin)*60;
movtT must be equal to 6.30, but it's 0.
You need to cast one of the operands of the division to be a double value. Like this:
double movT = ((double)distM/velMperMin)*60;
Your code performs integer division distM/velMperMin and that results in 0. You then multiply that by 60. Still 0. Then you convert to double and now it is 0.0.
Casting one of the operands to double ensures that the division will be a floating point division rather than an integer division and will yield the result you expect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With