The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 408 Weeks Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Rational r1= new Rational (3,5);
Rational r2= new Rational (4,7);
Rational r3=r1.add(r2);
// also sub,mult,divide methods
        Other that four operations you should provid methos that you think is useful for user of your class.
       2. Write a JFrame or JApplet (file name: TestRational.java) that performs the following tasks:
        a) Define two arrays of size 10. Each element in the array references to a Rational object that you wrote in Problem 1 above.
                  Rational a[], b[];
                  a = new Rational[10];
                  b = new Rational[10];
               Â
|
Rational |
|
Numerator                                                                                                                                                        Denominator |
                                     Â
|
                        |
| Â |
|
  .   .   .   .   . |
| Â |
        b) Initialize the arrays in Question a) by creating random Rational numbers. Do this by generating two      random numbers between 1 and 9 for each Rational and using the numbers as the numerator and    denominator. Denominator should be greater than Numerator. You should generate random numbers with Math.random.
        c) Display the contents of both arrays on the screen using JTextArea.
        d) Add a Scrollbar to JTextArea for scrolling up or down.
        e) For each public method in Rational class, create a corresponding JButton object. When the user clicks on a button, the actionPerformed listener should execute the corresponding Rational method for all the elements in the two arrays and store the results in a new array. You should then display the result array in the JTextArea using the setText method. For example, if the user hits the add button you should loop    through all the elements in arrays and execute:
 Â
                  c[i] = a[i].add(b[i]);
       Â
        f) If the user hits the sort button, uses the JTextArea method append to append the results of sorting.
Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â----------- -----------Â ----------- Â ----------- T-----------han-----------k Y-----------ou -----------for----------- us-----------ing----------- ou-----------r w-----------ebs-----------ite----------- an-----------d a-----------cqu-----------isi-----------tio-----------n o-----------f m-----------y p-----------ost-----------ed -----------sol-----------uti-----------on.----------- Pl-----------eas-----------e p-----------ing----------- me----------- on----------- ch-----------at -----------I a-----------m o-----------nli-----------ne -----------or -----------inb-----------ox -----------me -----------a m-----------ess-----------age-----------