Question
i am having difficulty with this homework question (Convert decimals to fractions) Write a program that prompts the user to enter a decimal number and
i am having difficulty with this homework question
(Convert decimals to fractions)
Write a program that prompts the user to enter a decimal number and displays the number in a fraction.
Hint: read the decimal number as a string, extract the integer part and fractional part from the string, and use the
Rational
class in LiveExample 13.13 to obtain a rational number for the decimal number. Use the template at
https://liveexample.pearsoncmg.com/test/Exercise13_19.txt
for your code.
Sample Run 1
Enter a decimal number: 3.25
The fraction number is 13/4
Sample Run 2
Enter a decimal number: -0.45452
The fraction number is -11363/25000
Class Name:
Exercise13_19
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