Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java Programming language Suppose we are designing a program to sort authors by their names. Author class has the following characteristics: o Implements Comparable

In Java Programming language image text in transcribed
image text in transcribed
Suppose we are designing a program to sort authors by their names. Author class has the following characteristics: o Implements Comparable interface. An author has first name, last name, and book. o A constructor that sets the previous 3 properties. o A compare To method that compares authors based on their names, starting with last name. A class that has the main method, In main: You are creating an arraylist of 5 authors, for example: Author: Deborah Hopkinson Book: Sky Boys Author: Frank Miller Book: 300 Author: Nalo Hopkinson Book: Brown Girl in the Ring Author: Henry Miller Book: Tropic of Cancer Author: George R. R. Martin Book: Song of Ice and Fire Sorting the authors arraylist contents. [Explanation: this is using the Compare To method in the Author class). A loop to print authors and their books in a sorted manner. Output: : Problems @ Javadoc Declaration Console X SortAuthByNames (Java Application) C:\Program Author: Deborah Hopkinson Book: Sky Boys --------- Author: Nalo Hopkinson Book: Brown Girl in the Ring - - - - - - - - Author: George R. R. Martin Book: Song of Ice and Fire --------- Author: Frank Miller Book: 300 - - - - - - - - - Author: Henry Miller Book: Tropic of Cancer

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

More Books

Students also viewed these Databases questions