CSc 331 - Spring 2018
Lab Exercise #1

Preparation

Exercise 1:

Copy the files ScanInts.java and ScanStrings.java from the directory ~hohman/331/s18/labs/lab1.

Exercise 2:

Design and code a Java class called Fraction. Fraction objects will have 2 private non-negative int members, representing the numerator and denominator of the fraction.

Fraction Constructors

Methods

Exercise 3:

Design and code a class AddFractions that will read and add a list of up to 10 fractions as shown below. I think you will need an array of Fraction's.

Notice that extra whitespace on an input line is ignored. Note that the Java String class has split and trim functions, and that the Integer class has the parseInt function

...$ java AddFractions
Let's add a list of fractions (no more than 10).
(Use ctrl/d to indicate the end of the list.)

Fraction 1: 3/8
Fraction 2:   1/12
Fraction 3: 11  / 6
Fraction 4: 2

3/8  +  1/12  +  1 5/6  +  2  =  4 7/24
...$

Submission:

This assignment is due at the beginning of the Tuesday lab class next week (3:30 p.m.) - and the submit program will enforce this!