import corejava.Console; import java.lang.Integer; import java.lang.String; //////////////////////////////////////////////////////////////////////////////////////////////////////// //Title :Test Program //Description: // This is a test program for the class Rational.Class Rational provides memeber functions for // performing arithmetic operations on Rational numbers.This test program allow the user to // enter Rational numbers.It uses the functions of the Rational class to determine the maximum // and sum of the Rational numbers entered by the user.It converts each rational number to its // lowest fraction and prints each Rational number as a string using the function toString of // the Rational class. //Inputs :The numerator and denominator of each rational element as enterd by the user //Outputs :The List of all rational elements entered by the user.Each element is printed as a string // :The sum of all rational elements entered by the user // :The maximum of all rational elements entered by the user //Local // Variables: // rationale,rationstr-instances of Rational class // int RationalArray[]-the array which holds the rational numbers // int MAXARRAY-number of rational numbers to be entered by the user // int ACTUALMAXARRAY-The totla no of numbers to be entered by the user. // int ArrayIndex-position of Rational element in the array // int counter-counts the number of Rational elements // SumofRationalElements-instance of rational class-holds the sum of all rational elements // entered by the user // MaxofRationalElements-instance of Rational class-holds the maximum of all rational elements // entered by the user ///////////////////////////////////////////////////////////////////////////////////////////////////////// public class RationalTest{ static Rational rationale,rationstr; //instances of Rational class public static void main( String[] args){ System.out.println("\nSample program to perform arithmetic on Rational numbers"); System.out.println("========================================================\n"); //create instances of the Rational class rationale=new Rational(); rationstr=new Rational(); //declare the array which holds the rational numbers int RationalArray[]; //read the number-MAXARRAY- of rational numbers to be entered by the user int MAXARRAY = Console.readInt("Enter the number of rational numbers you will be entering : "); //The total no. of numbers which is the user enters is twice (Numerator and denominator) the ACTUALMAXARRAY int ACTUALMAXARRAY=2*MAXARRAY; RationalArray = new int[2*MAXARRAY]; //declare the size of the array int ArrayIndex,counter=1; //Fill in array with the input numerator and denominator for(ArrayIndex=0;ArrayIndex