Exercises
1. Add a Convert button to the fraction calculator application. When the button is pressed, use the Fraction class’s convertToNum method to produce the numeric representation of the fractional result. Convert that result to a string and show it in the calculator’s display.
2. Modify the fraction calculator application so that a negative fraction can be entered if the – key gets pressed before a numerator is entered.
3. If the value of zero is keyed in for a denominator for either the first or second operand, display the string Error in the fraction calculator’s display.
4. Modify the fraction calculator application so that calculations can be chained. For example, allow for the following operation to be keyed:
1/5 + 2/7 – 3/8 =
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access