Answered You can hire a professional tutor to get the answer.

QUESTION

Change your fraction class so that its instance variables numerator and denominator are hidden (i. private ). Check that your old client class will...

1. Change your fraction class so that its instance variables numerator and denominator are hidden (i.e. private). Check that your old client class will not now compile (i.e, if the Fraction class instance variable name ‘numerator’ was used in the client class).

2. Add a public method isZero to your fraction class for testing whether the calling fraction is equal to the number zero. Modify your old client class so that it now loops until a fraction representing zero is entered.

3. Add two more public methods: equals which determines whether two fractions represent the same number and add which adds another fraction to the calling fraction and returns a fraction result. Make a client which loops around getting two fractions from the user and outputting their sum and whether or not they are equal. Keep looping until the first fraction entered is zero.

4.  Now you are required to change the implementation of your fraction class without making any changes to the client program from question 3.

You are required to ensure that fractions are stored with denominators which are positive integers. You can require the user to only enter such fractions but you should check their input. The user should not really be inconvenienced by such a restriction as, for example, 1/-2 is the same as  -1/2.

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question