Question: How can I add a quick sort to this program and not return the [Ljava.lang.Object;@5dfcfece with the results? The program should provide the contents of

How can I add a quick sort to this program and not return the [Ljava.lang.Object;@5dfcfece with the results?

The program should provide the contents of the queue and then sort the queue using the quick sort in two ways:

  • Descending order by last name.
  • Descending order by age.

import java.util.LinkedList; import java.util.Scanner;

public class personQueue

{ private static Scanner scnr;

public static void main(String[] args)

{

LinkedListtheQ = new LinkedList < > (); scnr = new Scanner(System.in); int i; for (i = 0; i < 5; i++) { System.out.println("Enter the fist name of the person in queue position " + (i + 1) + ": "); String first = scnr.next(); System.out.println("Enter the last name of the person in queue position " + (i + 1) + ": "); String last = scnr.next(); System.out.println("Enter the age of the person in queue position " + (i + 1) + ": "); int age = scnr.nextInt(); theQ.add(new Person(first, last, age)); } System.out.print(theQ.toArray()); for (int j = 0; j < theQ.toArray().length; j++) { System.out.println(theQ.toArray()[j].toString()); } } }

public class Person implements Comparable < Person > { String first; String last; int age;

public Person(String firstName, String lastName, int age) { this.first = firstName; this.last = lastName; this.age = age; } public String toString() {; return " " + this.first + " " + this.last + " " + this.age + " "; } public int compareTo(Person arg0) { return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!