id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

andersoniii.edwin@cusd80.com > decimalToFraction
prev  |  next  |  chance

Write the method that receives a decimal number (between 0 and 1) and returns an array where in subscript zero is the numerator and subscript one is the denominator. Place the numerator into the zero subscript and the denominator into the first subscript location of the answer. EXAMPLES: .5 -> [1,2] and .05 ->[1,20] and .125 -> [1,8]


decimalToFraction(0.5) → [1, 2]
decimalToFraction(0.05) → [1, 20]
decimalToFraction(0.123) → [123, 1000]

...Save, Compile, Run (ctrl-enter)

public int[] decimalToFraction(double dec){ }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 170 Post-solution available

Copyright Nick Parlante 2017 - privacy