Question: Approximate decimal to fraction. /** * Constructor - HD Level(20 marks) * * @param dec * :double - The decimal to approximate * * Write

Approximate decimal to fraction. /** * Constructor - HD Level(20 marks) * * @param dec * :double - The decimal to approximate * * Write an algorithm which finds an approximation of the fractional form of a decimal. * * Set the instance parameters to the numerator and denominator found in the approximation. * * You may assume that d is a positive number with only 2 decimal places. * * Your approximation must be correct to 2 decimal places. * * Hint: * * There are many ways to do this, but there is one very easy approach * which cannot be found on the internet. * * Examples: * * 0.333 -> 1/3 * * 0.25 -> 1/4 * * 0.66 -> 2/3 * * 0.67 -> 19/28 * * 5.78 -> 81/14 * * 5.75 -> 23/4 * */ public Fraction(double dec) {

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!