The boxed information below comes from  Data Structures with Ada  by Michael B. Feldman published by Reston in 1985.  So does some of the code in this assignment.

 

Some reminders:

1.    a data type is the set of values valid for a variable.

2.    an abstract data type is a data type together with a set of operations valid for that type

3.    a data structure is a concrete way of implementing an abstract data type.

 

 

Programming languages usually have support for real numbers but usually do not have support for fractions.  There are certain applications where fractions are useful.  We might want to represent the number 1/3 exactly and not as  0.333  This requires that we have a way to remember the numerator and denominator. 

 

Here are some questions relating to the Fractions package.  You should come to class on Monday prepared to answer them.

 

Why do we declare the numerator as an integer but the denominator as a positive?

Because the denominator can’t be zero

Why do we not have a function “<=”?

We don’t need it. We can test for = and then test for <

Why do we multiply both the numerator and the denominator of a fraction by -1 if the denominator is less than 0?

To conform to the specification which declares the numerator as an integer (which means it is allowed to be negative) but the denominator is declared as a positive (which means it is not allowed to be negative). 

According to our specification, is it legal to have a fraction in which the numerator is larger than the denominator?

Yes.  There is no restriction that says that the faction has to be a proper fraction.

How do we reduce a fraction?

we find the greatest common factor and then divide the numerator and denominator by that factor.

Does the function “-“ work correctly?

Yes it does.

Which functions should include a call to Reduce before returning their result?

Addition, subtraction, multiplcation and division – WHAT DO WE DO ABOUT MAKE_FRACTION????