import java.io.IOException;
import java.io.FileReader;
import java.io.BufferedReader;

class DataHelper 
{
	private Entry[] data;

	public DataHelper(int size) 
	{
		data = new Entry[size];
		int k = 0;
		try{
			FileReader fr = new FileReader("StudentWork/Workday2/data.txt");
			BufferedReader br = new BufferedReader(fr);

			String line = br.readLine();
			while(line != null)
			{
				double x = Double.parseDouble(line.substring(0, line.indexOf(",")));
				line = line.substring(line.indexOf(",")+1);
				double y = Double.parseDouble(line.substring(0, line.indexOf(",")));
				line = line.substring(line.indexOf(",")+1);
				double thickness = Double.parseDouble(line);

				data[k] = new Entry(k+1, x, y, thickness);
				k++;
				line = br.readLine();
			}

			br.close();
			fr.close();
		}catch(IOException e2){}
	}

	public Entry[] getData() 
	{
		return data;
	}
}

class Entry 
{
	//create PIV's
	int recordNumber; 
    double gpsX, gpsY, thickness;
	
	//write the constructor with the appropriate parameter list
	public Entry(int recordNumber, double gpsX, double gpsY, double thickness) 
	{
		this.recordNumber = recordNumber;
        this.gpsX = gpsX;
        this.gpsY = gpsY;
        this.thickness = thickness;
		
	}

	//write the getThickness method
	public double getThickness() 
	{
		return thickness;
	}

	//write the toString method
	public String toString() 
	{
		String number = "" + recordNumber;

        // this for loop forces the string to contain 4 characters to keep numbers in the column, not necessary for students to use
        for(int i = 0; i < 4 - number.length(); i++)
        {
            number += " ";
        }

        String gps = "" + gpsX + ", " + gpsY;
        
        // this for loop forces the string to contain 16 characters to keep numbers in the column, not necessary for students to use
        for(int i = 0; i < 16 - gps.length(); i++)
        {
            gps += " ";
        }

        return number + "\t" + gps + "\t" + thickness + "km";
	}

}

public class Main 
{
	public static void main(String[] args) 
	{
    
		DataHelper helper = new DataHelper(50);

		Entry[] dataList = helper.getData();		
		Entry[] selectionSort = new Entry[50];
		Entry[] insertionSort = new Entry[50];
		
		//write the code to load all the values from 
		//dataList into the selectionSort and 
		//insertionSort arrays
        


		System.out.println(dataList[0] + "\n" + selectionSort[0] + "\n" + insertionSort[0] + "\n");
		

		// Linear Search
	
		
		// Target is 4.63 for this sample
    
    
    
		System.out.println("Sorted data using a selection sort:");

		// Selection Sort
		
		
   
    
		//print out the sorted data
		for(Entry e : selectionSort)
		{
			System.out.println(e);
		}

	
		System.out.println("\nSorted data using a insertion sort:");

		// Insertion Sort
		
		
    
		//print out the sorted data
		for(Entry e : insertionSort) 
		{
			System.out.println(e);
		}
	
	}
}


data.txt:
-76.783,-104.6,3.38
-75.809,-81.216,4.09
-76.11,-92.196,2.61
-79.732,-146.625,2.59
-78.405,-137.185,1.6
-78.816,-87.483,1.96
-71.849,-105.724,3.27
-75.165,-143.099,1.75
-81.543,-132.752,1.5
-81.555,-115.245,3.48
-75.906,-136.273,1.89
-71.903,-106.182,3.96
-80.859,-116.829,3.15
-74.766,-122.872,2.55
-80.644,-130.913,2.41
-75.14,-84.377,3.28
-74.888,-88.249,2.39
-75.484,-145.537,4.23
-79.729,-90.392,4.72
-80.784,-115.712,2.02
-77.431,-128.127,4.67
-74.757,-85.794,2.15
-77.129,-107.967,3.83
-78.18,-81.709,2.78
-75.354,-83.303,2.89
-76.682,-122.226,2.51
-71.692,-87.324,4.3
-76.737,-119.296,2.07
-77.577,-108.533,3.27
-74.626,-142.541,1.53
-72.253,-89.148,2.06
-71.988,-126.727,4.04
-75.503,-103.192,2.76
-77.386,-119.205,4.51
-81.233,-82.702,2.19
-73.401,-146.565,4.58
-81.595,-115.824,2.45
-77.994,-120.486,4.6
-79.749,-121.272,2.54
-72.895,-91.681,1.63
-79.749,-104.742,3.11
-79.267,-99.575,4.63
-79.99,-111.359,2.57
-78.706,-125.206,4.36
-80.067,-144.711,4.36
-77.393,-127.042,1.27
-80.574,-82.205,1.43
-82.037,-116.204,4.42
-76.249,-122.96,1.24
-80.757,-82.289,4.47

Write the code to load all the values from dataList into the selectionSort and insertionSort
Write the code for 2 linear search algorithms in the main() method of the Main class:
To find and print the item with the largest ice thickness value in the dataset.
To find and print a specific item (ice thickness value of 4.63) in the dataset. If it doesn’t exist, print an appropriate message.
Code the implementation of these algorithms under the comments that say 'Linear Search’.

You will need to write an algorithm that implements a Selection Sort on the dataset.
Sort the data based on the ice thickness values, least to greatest.
Don’t forget to use the Entry class as a reference when trying to determine how to write the algorithm.
Code the implementation of these algorithms under the comments that say 'Selection Sort’.
Uncomment the line(s) to print out the selectionSort array in order to test your algorithm.

Sort the data based on the ice thickness values, least to greatest.
Don’t forget to use the Entry class as a reference when trying to determine how to write the algorithm.
Code the implementation of these algorithms under the comments that say 'Insertion Sort’.