

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A project for a cse 1301 class, where students are required to define a rational class with constructors, arithmetic and logical methods, and setters and getters. The project also includes an extra credit assignment to add a greatestcommondivisor method. Specifications and examples for the input and output of the program.
Typology: Study Guides, Projects, Research
1 / 2
This page cannot be seen from the preview
Don't miss anything!


CSE 1301 Project# Rational Number Class Due: Monday July 13, 2009 Define the Rational class according to the specifications given on the handout and in class discussions Define 3 constructors and a toString method, setters, and getters Define arithmetic methods for add, subtract, multiply, divide, and negate. Define logical methods for equals, notEquals, lessThan, lessThanOrEqual, greaterThan, and greaterThanOrEqual. All negative values should be represented with – sign in the numerator Extra Credit: add a greatestCommonDivisor method to reduce a Rational number to its lowest terms. If you write this method, add the reduced values to your output. For example: ½ + ¾ = 10/8 reduced to 5/ Run three times with the following data: (read in the data then use one of the constructors or the setter methods to fill objects with data) Input 1: 1/2, 3/ Input 2: 1/2, 16/ Input 3: 3/-5, 2 Output (using the first set of numbers): Rational 1 –> ½ reduced to _______ Rational 2 -> ¾ reduced to_______ ½ + ¾ ______ reduced to_______ ½ - ¾______ reduced to_______ ½ * ¾ ______ reduced to_______ ½ / ¾______ reduced to_______
Submit a UML for the whole application rather than an algorithm for main. The UML will be page 2 of the folder (after the assignment sheet). NOTE: This project is due the class day after Quiz 2 but the material on this project is covered in Quiz 2. Be sure to complete this project before the due date to be completely prepared for the quiz. I just didn’t want to make it due on the day of the quiz.