Question
Need help solving this code Create a class called Fractions. A fraction contains a numerator and a demoninator. Both the numerator and the denominator are
Need help solving this code
Create a class called Fractions. A fraction contains a numerator and a demoninator. Both the numerator and the denominator are integers.
1) Prompt the user for the first fraction. Prompt for a numerator and then a denominator.
2) Once the numerator and denominator have been entered. Print out the fraction in its simplest form. Here are some examples: a. Numerator is 2, demonimator is 3. You print 2/3 b. Numerator is 2, denominator is 4. You print 1/2 c. Numerator is 3, denominator is -4. You print -3/4 d. Numerator is -3, denominator is -4. You print 3/4 e. Numerator is 2, denominator is 2. You print 1 f. Numerator is 0, denominator is 1. You print 0 Loop until valid numerators and denominators are entered. 0 is not a valid demoninator.
3) Prompt the user for the second fraction. Prompt for a numerator and then a denominator. Print out as you have done for the first fraction.
4) Print of the following results in the following format: 2/3 + 3/4 = 17/12 = 1 5/12 2/3 3/4 2/3 * 3/4 = 1/2 2/3 3/4 = 8/9 2/3 < 3/4
Sample session:
Please enter the first numerator> a
Please enter an integer> 2
Please enter the first denominator> 0
Please enter an non-zero integer> -4 -1/2
Please enter the second numerator> 10
Please enter the second denominator> 7 1 3/7
-1/2 + 1 3/7 = 13/14
-1/2 - 1 3/7 = -1 13/14
-1/2 * 1 3/7 = -5/7
-1/2 / 1 3/7 = -7/20
-1/2 < 1 3/7
false
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