Java Application with Class Structure

1. Program Description Constructors:
The class Rational provides 2 constructors:
1. One constructor function that initializes an object with an initial numerator and denominator (and reduces the fraction to lowest terms).
So 4/8 is reduced to 1/2
2. A second default constructor function that takes no arguments and initializes the number to some default value.
ie. say 0 .So numerator is 0 and the denominator is 1.The number is 0/1.

Greatest Common divisor function
This class should provide a function to convert all fractions to the lowest term.The rational elements enterd by the user are stored
in the lowest terms and the result of all arithmetic operations on these fractions are converted to their lowest terms.

Other Functionality
This class should include functions to perform arithmetic on rational numbers.The result of this and all the remaining methods should be in lowest terms.

The following functionality should be provided:
 

Test Program 2. Description of the Algorithm and Overview of the Program


Description of class Rational and functions
 

Public class Rational{

        public Rational(int numeratorval,int denominatorval)         //Initiallizing Constructor                
        public Rational()                                            //Default Constructor                    
        public void getnumdenom(int numeratorval,int denominatorval) //initiallizes the numerator and denominator 
                                                                     //of a rational object    
        public Rational Addition(Rational r1,Rational r2)            //Addition of 2 Rational numbers      
        public Rational Subtraction(Rational r1,Rational r2)         //Subtraction of 2 Rational numbers   
        public Rational Multiplication(Rational r1,Rational r2)      //Multiplication of 2 Rational numbers
        public Rational Comparision(Rational r1,Rational r2)         //Comparision of 2 Rational numbers
        public void toString(Rational r1)                            //forms a string with the Numerator   
                                                                     //and denominator of r1,with "/" in b/w/
        private int gcf (int value1, int value2)                     //obtains the gcd of 2 Rational numbers
        }               


Functions

3. References by Lakshmi Anumolu