Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help on a JAVA program - a program that creates a Person class that conta

ID: 3605751 • Letter: I

Question

I need help on a JAVA program - a program that creates a Person class that contains strings that represent the first and last name of a person and their age. You will need to create a Queue class that will store each person in the queue and can sort the queue based on last name or age.

Prompt the user of the program to add five people to the queue. Your 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.

Explanation / Answer

public Person(String firstName, String lastName, int age)

   public class Person

{  

       private String Firstname;

        private String Lastname;

        private String Name1;

        private int getAge;

        private int birthday;

        private int newAge;

        private int age1;

public Person(String first, String last, int age)

    {

      Firstname = first;

      Lastname = last;

        age1 = age;

    }

       public String getName()

           {

       String getName = "Lastname , Firstname";

       Name1 = Lastname + ", " + Firstname;

       return Name1;

    }

        public int getAge()

        {

       return age1;

    }

        public int birthday()

        {

       age1++;

       return age1;

    }

}

Please find the beow code also

import java.util.Scanner;

public class Alphabetical_Order

{

    public static void main(String[] args)

    {

        int n;

        String temp;

        Scanner s = new Scanner(System.in);

        System.out.print("Enter number of names you want to enter:");

        n = s.nextInt();

        String names[] = new String[n];

        Scanner s1 = new Scanner(System.in);

        System.out.println("Enter all the names:");

        for(int i = 0; i < n; i++)

        {

            names[i] = s1.nextLine();

        }

        for (int i = 0; i < n; i++)

        {

            for (int j = i + 1; j < n; j++)

            {

                if (names[i].compareTo(names[j])>0)

                {

                    temp = names[i];

                    names[i] = names[j];

                    names[j] = temp;

                }

            }

        }

        System.out.print("Names in Sorted Order:");

        for (int i = 0; i < n - 1; i++)

        {

            System.out.print(names[i] + ",");

        }

        System.out.print(names[n - 1]);

    }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote