All pastes #930236 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-03-06 12:05 UTC
rendered paste body
package djsExtraCredit;


public class ExtraCreditController {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		//create variables to hold information collected from the user
		int i;
		int j;
		int n = 10;
		int[] a = new int[] {1,2,3,5,6,0,9,4,8,7};
		String[] record = new String[] {"Bob","Frank","dill","mom","pop","jak","farfenhowser","your mom","toodles","hi"};
		int tmp;
		String tmpRecord;
		
		for (i=0; i<n-1; i++) {
			  for (j=0; j<n-1-i; j++)
			    if (a[j+1] < a[j]) {  /* compare the two neighbors */
			      tmp = a[j];         /* swap a[j] and a[j+1]      */
			      a[j] = a[j+1];
			      a[j+1] = tmp;
			      // repeat to actual records
			      tmpRecord = record[j];
			      record[j] = record[j+1];
			      record[j+1] = tmpRecord;
			  }
			}
		for(i=0;i<10;i++){
			System.out.println(a[i]+" "+record[i]);
		}
	}
}