In this example, you will learn how to convert decimal number to Fraction. The following program you convert it into the decimal to fraction value by using doubleValue() method..
In this program you will also learn how to convert a decimal number into fraction with the help of valueOf() method. Define the class named "DecimalToFraction" for the java component. This program takes a string type value and store it in an integer type variable by using parseInt() method which converts decimal number into fraction by using doubleValue() method.
Here is the code of this program:
Output of this program.
Enter the decimal number
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: July 10, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles