// Arup Guha
// 6/8/2010
// Framework for Computer Science II Recitation #4 assignment

// Solution written on 6/15/2010

import java.util.*;

public class BucketSortScaffold {
	
	public static void main(String[] args) {
		
		Scanner stdin = new Scanner(System.in);
		
		// Get user input values.
		System.out.println("Please enter the number of values to sort.");
		int numVals = stdin.nextInt();
		System.out.println("Please enter the low range for your values.");
		int low = stdin.nextInt();
		System.out.println("Please enter the high range for your values (not inclusive).");
		int high = stdin.nextInt();
		
		double[] array = makeRandomArray(low, high, numVals);
		
		// Only for debugging
		//print(array);
		
		// Sort
	    bucketSort(array, low, high);
	    
		// Only for debugging
		//print(array);
			
		if (isSorted(array))
			System.out.println("Your array is properly sorted.");
	}
	
	// Pre-condition: The items in array are in the range [low, high).
	// Post-condition: array will be sorted using a bucket sort.
	public static void bucketSort(double[] array, int low, int high) {
		
		// FILL THIS IN!!!
	}
	
	
	// Returns an array of doubles storing n random values in the range
	// [low, high).
	public static double[] makeRandomArray(int low, int high, int n) {
		
		double[] array = new double[n];
		
		// Each value is filled in - Math.random returns a number in [0,1).
		for (int i=0; i<n; i++)
			array[i] = low + Math.random()*(high - low);
			
		return array;
	}
	
	// Return true iff vals is sorted in non-decreasing order.
	public static boolean isSorted(double[] vals) {
		
		// Return false if any two consecutive items are out of order.
		for (int i=0; i<vals.length-1; i++)
			if (vals[i] > vals[i+1])
				return false;
				
		// Must be sorted if we get here.
		return true;
	}
	
	// for debugging purposes
	public static void print(double[] array) {
		for (int i=0; i<array.length; i++)
			System.out.printf("%.2f ",array[i]);
			
		System.out.println();
	}
}