CE00371-1 INTRODUCTION TO SOFTWARE DEVELOPMENT


Lab/Tutorial 7

Assessment weight : 3%

Due : Week 9

Programming exercises.

  1. For an array a with n elements, write a method bubleSort(array) which takes in an array as the parameter and sorts the array in desending order using the following algorithm:
             for i from 0 to n - 2 do
                for j from n-1 down to i + 1 do
                   if a[j-1] < a[j] 
                      swap a[j-1] and a[j] 
    		
    
    To test your bubleSort() method, modify again, your program which you have written for Question 6 of Lab3 to make use of an array to store user inputs, print the largest and smallest value after sorting i.e. the first and last array element.

  2. Use the Rational class given in your note, create an applet to test the Rational class.

    You do not have to implement any new method for Rational class. Your applet should look and function like this : GUIRationalDriver

  3. Publish your answers after you finished.