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 Fraction.java CS152.HW1
% mv TestFraction.java CS152.HW1
% share CS152.HW1
% cs CS152.HW1
% share Fraction.java
% share TestFraction.java

Assignment

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.

History

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 http://www.cs.grinnell.edu/~rebelsky/Courses/CS152/2000F/Homeworks/hw.01.html

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 rebelsky@grinnell.edu