COSC 1337, Professor Clark Assignment 5: 10 Points
COSC 1337, Professor Clark Assignment 5: 10 Points
Assignment 5: 10 points
Program Description:
Design and implement an immutable Fraction Class as described in lecture. Your class must have the
following methods to emulate arithmetic, relational, and output operations on Fractions.
Specific Requirements:
Your main testing program will have two variables: start and userFraction which are both of
type Fraction.
start should contain values set by you that are passed into the constructor.
userFraction will contain values entered by the user.
There are to be no get/set methods for the Fraction class. Having get/set methods in your class
will cause you to lose significant points.
Any time you see a fraction printed in the form x/y in the output, it is because we have printed
the Fraction object. Do not hold and print your own copies of numerators and denominators in
the tester class.
Be sure to test your program with several different fractions, but for your output you report to me, use
the exact test values from the example output. Demonstrate all methods implemented.
Helpful notes:
You should have two different .java files with this project – Fraction.java and your tester class
You may consider making a private helper method or two for simplifying your fraction.
Grading Rubric:
Create a folder with your name as the name of the folder (YourLastName )
In your favorite IDE, begin work on the lab.
o Use the folder as the source/destination of the project/files
When finished working the lab, ‘zip’ the folder into ONE file
Go into Canvas and submit the lab as usual using the ‘zip’ file.
Bring to class:
A printout of your source code for the program and the output generated.
Note: Don’t forget to have a comment header at the top of your programs that contains your
name, date, and the purpose of the program
Example output:
We will start with the fraction 3/5.
Enter a second fraction in the form numerator <space> denominator:
8 12
Your simplified fraction is: 2/3
********************************
Demonstrating math operators: -, +, *, /
This will show negation of 3/5 and then our two fractions
3/5 and 2/3 added, multiplied, and divided.
-: -3/5
+: 19/15
*: 2/5
/: 9/10
********************************
Demonstrating relational operators: <, <=, >, >=, ==, !=
by comparing 3/5 with 2/3.
<: true
<=: true
>: false
>=: false
==: false
!=: true
********************************