Please make this java program work
Instruction: Write a test program that inputs, sorts, outputs Integer and Float. And call the isEqualTo method.
import java.util.*;
public class Generics { public static < e=""> void printArray( E inputArray[] ) { // Display array elements for( E element : inputArray) { System.out.printf("%s ", element); } System.out.println(); } public static < e="" extends=""> > void selectionSort(E array[]){ int size = array.length; for (int i = 0; i < size-1;=""> // Find the minimum element int min = i; for (int j = i+1; j < size;=""> if (array[j].compareTo(array[min]) <> min = j; // Swap the found minimum element with the first element E temp = array[min]; array[min] = array[i]; array[i] = temp; } } public static < e=""> boolean isEqualTo(E inputArray, E inputArray2){ //if (inputArray == inputArray2){ // System.out.println("TRUE"); //} //else{ // System.out.println("FALSE"); //} return inputArray.equals(inputArray2); } public static void main(String[] args) { // TODO code application logic here Scanner sc = new Scanner(System.in); System.out.println("Enter the number of Integers: "); int int_num = sc.nextInt(); System.out.println("Enter the number of Float numbers: "); int float_num = sc.nextInt(); Integer[] n = new Integer[int_num]; //generic integer array Float[] f = new Float[float_num]; //generic float array System.out.println("Enter Integers: "); for(int i = 0; i < int_num;=""> int x = sc.nextInt(); n[i] = x; } System.out.println("Enter Float numbers: "); for(int i = 0; i < float_num;=""> float y = sc.nextFloat(); f[i] = y; } selectionSort(n); System.out.println("Sorted Integers: "); printArray(n); selectionSort(f); System.out.println("Sorted Float numbers: "); printArray(f); System.out.println("Are they equal?"); if(isEqualTo(n,f)){ System.out.println("TRUE"); } else{ System.out.println("FALSE"); } }}
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here