Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started