Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions