Fundamentals of Computer Science II (CSC-152 2000F)

Homework 1: A Fraction Class

Summary: For this assignment, you will write a Java class so as to familiarize yourself with the components and techniques for writing Java programs. You may not have learned all the information for this assignment by the time it was assigned, you will have learned it well in advance of the due date for the assignment.

Group work: You should each write your own classes. However, you may discuss the assignment with each other and help each other correct problems.

Turning it in: Leave your code in a publically readable directory, and email me the location of that directory. Here's some sample Unix code for setting up the directory.

% mkdir CS152.HW1
% mv CS152.HW1
% mv CS152.HW1
% share CS152.HW1
% cs CS152.HW1
% share
% share


In class, we began to consider a simple Faction class that implements simple fractions, with a numerator and denominator. Finish writing the basic class (we may add more facilities in the next assignment). You need not do anything special with nonpositive denominators.

Your Fraction class should provide the following constructors

Your Fraction class should provide the following methods

Once you have completed your basic class, create a class, TestFraction that provides a main routine that appropriate tests your routines. Here are some things that you might test:

Extra Credit

Be creative in your choice of additional facilities for the Fraction class.


Wednesday, 30 August 2000

Friday, 1 September 2000

Monday, 4 September 2000

Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.

This page may be found at

Source text last modified Mon Sep 4 09:38:09 2000.

This page generated on Mon Sep 4 09:37:32 2000 by Siteweaver. Validate this page's HTML.

Contact our webmaster at