Question
Could someone help me code the following lab in JAVA? I'm a little confused by it, and I would appreciate // marks where you tell
Could someone help me code the following lab in JAVA? I'm a little confused by it, and I would appreciate // marks where you tell me what you did so I can follow along.
Part One:
Create a class called Person.java that implements Comparable (remember, the Comparable Interface is already built into Java, you dont have to write it). Include at least two data fields, a constructor, accessor methods, a toString method and the required compareTo method.
Choose your own data fields and your own implementation for compareTo.
Part Two:
Create a driver that asks the user how many people they would like to enter. Create an array of Person objects of that size.
Have the user "create" each person by entering all data fields.
After the last Person is entered, perform an insertion sort by calling Person's compareTo method.
Insertion sort must be a separate method that you call from main. The method header should look like:
public static void insertionSort(Person[] list)
Output your sorted array and verify that the elements are in ascending order.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started