CS210 Lab: Software Engineering Principles Postlab
This postlab exercise asks you to modify the code for the fraction class.
Click here to download this project
We have decided to change the specifications.
We would like to be able to store a fraction in its proper or improper form.
In it's proper form, it should be reduced.
When a number is converted to proper form, the whole number should be stored.
We should also allow the conversion from improper to proper and from
proper to improper.
However, we will assume that the input remains in numerator/denominator format.
To summarize, we will have data members:
We will have member functions:
takes two integer values and stores them in
num and denom
returns the value of num
returns the value of denom
checks whether the numerator and denominator
have a common factor and, if they do, divides
both by the common factor. Stores the result
in num and denom.
tests whether the fraction is zero.
A fraction is zero if the numerator is zero
and the denominator is 1.
tests if the numerator is greater than or
equal to the denominator.
reduces the fraction, and stores the whole-number
part and leaves the remaining part in the fraction.
converts the whole number back into a fraction.
Whole will be 0 and fraction will be the reduced
- Implement this as code.
- Develop a test plan for the modified ConvertToProper and
the new ConvertToImproper member functions
For Answers, click
Back to Software Engineering Principles Lab click
Copyright: Department of Computer Science, University of Regina.