Answered step by step
Verified Expert Solution
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started