< Back

Lecture 12 - Day 1 of Java


Esoteric "Today"


Activity

Webber, Chapter 13, Exercise 10.

Homework

DUE WEDNESDAY, FEB. 24TH. Submit your java files to inquire by the beginning of class.

Details

Write a class in Java called Fraction, which represents a generic fraction object. Towards that end, you must have:

  1. Two pieces of member data: numerator and denominator.
  2. A constructor that allows you to create a fraction by specifying the numerator and denominator.
  3. Four methods: add(otherFraction), sub(otherFraction), mul(otherFraction), and div(otherFraction). These should return a new Fraction object, as opposed to modifying the current fraction object.

Create a program you can use to test your program. Make sure you test all of the methods of your classes.