Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

how to covert fraction to decimal in java /** * Method: toDecimal (5 marks) * * @param dp * :int - The number of decimal

how to covert fraction to decimal in java /** * Method: toDecimal (5 marks) * * @param dp * :int - The number of decimal places * * @return * :double - The decimal form of the fraction truncated to dp decimal places. * * Hint: You may use the Math.round and Math.pow methods. * * Example: * * If dp = 2: * * 1/4 -> 0.25 * * 5/4 -> 1.25 * * 5/11 -> 0.45 * * 1/3 -> 0.33 * * 2/3 -> 0.66 * * If dp = 4: * * 1/4 -> 0.25 * * 5/4 -> 1.25 * * 5/11 -> 0.4545 * * 1/3 -> 0.3333 * * 2/3 -> 0.6666 * */ public double toDecimal(int dp) { }

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

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago