Please make this java program work  Instruction: Write a test program that inputs, sorts, outputs Integer and Float. And call the isEqualTo method.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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 <E>{
   
    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 Comparable<E> > void selectionSort(E array[]){
        int size = array.length;
        
         for (int i = 0; i < size-1; i++){
            // Find the minimum element
            int min = i;
            for (int j = i+1; j < size; j++)
                if (array[j].compareTo(array[min]) < 0)
                    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; i++){
            int x = sc.nextInt();
            n[i] = x;
        }
        
        System.out.println("Enter Float numbers: ");
        for(int i = 0; i < float_num; i++){
            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");
        }
    }
    
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY