Assignment 8 - For maxElement = arraySize 1 To = Step -1...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CIS 110 David Kegler 6/8/2011 Assignment 8 Module Main () //Declare constants for the array size Constant Integer SIZE = 10 //Golf score array getGS (GS, SIZE) //For sorting the golf scores bubbleSort (GS, SIZE) //Golf score display Display “Here are your golf scores” Display “sorted from lowest to highest” showGS (GS, SIZE) End Module //The GS module prompts the user to enter the golf scores Module GS(Integer Ref array[], Integer arraySize) //Counter variable Declare Integer index //Get the golf scores For index = 0 to arraySize – 1 Display “Please enter your score”, index + 1 Input array[index] End For End Module //The bubblesort module accepts and sorts the user inputs Module bubbleSort(Integer Ref array[], Integer arraySize) //The maxElement variable will contain the subscript of the last element in the array to compare Declare Integer maxElement //The index variable will be used as a counter in the inner loop Declare Integer index
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: For maxElement = arraySize 1 To = Step -1 //The inner loop steps through the array, comparing each element For index = 0 To maxElement 1 //Compares each element with its neighbor and swaps if necessary If array[index] > array[index + 1] Then Call swap(array[index, array[index + 1]) End If End For CIS 110 David Kegler 6/8/2011 Assignment 8 End For End Module //The swap module accepts two Integer arguments and swaps their contents Module swap(Integer Ref a, Integer Ref b) //Local variables for temp storage Declare Integer temp //Swap the values a and b Set temp = a Set a = b Set b = temp End Module //The showGS module displays the contents of the array that is passed as an argument. Module showGS(Integer array, Integer arraySize) //Counter variable Declare Integer index //Display the golf scores For index = 0 to arraySize 1 Display array[index] End For End Module...
View Full Document

This note was uploaded on 02/17/2012 for the course CIS 110 110 taught by Professor Tucker during the Spring '11 term at Strayer.

Page1 / 2

Assignment 8 - For maxElement = arraySize 1 To = Step -1...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online