Given  two integer variables distance and speed, write an expression that divides distance by speed using floating point  arithmetic, i.e. a fractional result should be produced.

LANGUAGE: JAVA

CHALLENGE:

Given  two integer variables distance and speed, write an expression that divides distance by speed using floating point  arithmetic, i.e. a fractional result should be produced.

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,

2 Comments

  1. hunter on April 20, 2015 at 2:44 pm

    or “(float) distance / speed”

    • help on July 1, 2015 at 10:44 pm

      For exact answers in this case, use double. float can result in a rounding error.

Leave a Comment

You must be logged in to post a comment.