Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

10. (Total 8 marks) Write a java program that has a class called Book with the attributes name, author, price, type (sciencefiction, comedy, thriller). Use

image text in transcribedimage text in transcribedimage text in transcribed

10. (Total 8 marks) Write a java program that has a class called Book with the attributes name, author, price, type (sciencefiction, comedy, thriller). Use input methods to get the input values. Create three arraylists (sciencefiction, comedy and thriller). - For each type of book, insert/hardcode the book object into the respective arraylist. Add two books each as shown in the example program output for each arraylist (sciencefiction, comedy and thriller). (Hint: no need for scanner input) - Display the list of books in each type as shown in the output. - Sort and display the list of books in each list by the book name as shown in the program output. - Display the minimum and maximum priced books of each list as shown in the program output. REQUIREMENTS Book class: - Implements Serializable - It has 4 data fields - String name; string author; float price; string type; - It has the first constructor that takes 4 arguments, i.e., Book (String name, String author, float price, string type). - It has a second constructor that takes 4 arguments, i.e., set_values (String name, string author, float price, String type). - It has print_book () that prints the book name, author, price and type for each book on a separate line as shown in example program output. BookArraylist class: - Includes three arraylist - one each for sciencefiction, comedy and thriller type - Hardcode 2 books for each type - sciencefiction, comedy and thriller (6 books in total) - It has print_book () that prints the book name, author, price and type for each book on a separate line as shown in example program output. - Call NameComparator () and PriceComparator () for sorting based on name and price - Include methods to show output as shown in the example program output. Example of the program Books in the sciencefiction list: Name: Brief History of Tine Author: Stephen Harking Price: 43.0 TYpe: sciencefiction Name: The Unidentified Author: Colin Dickey Price: 53.0 Type: sciencefiction Books in the comedy list: Name: Scoop Auchor: Zvelyn Waugh Price: 45.0 Type: comedy Name: My LAfey Author: Paddy MeCuinness Price: 29.0 TYpe: comedy Books in the thriller list: Name: Wild Place Author: Christian White Price: 47.0 Type: thridler Name: The Guest List Author: Iuey Joley Price: 23.0 TyPe: thriller Sorting seiencedietion list based on names: Brief History of Time Sorting sciencefiction list based on names: Brief History of Time The Unidentified Sorting comedy list based on names: My Lifey Scoop Sorting thriller list based on names: The Guest Iist wild Place Sorting sciencefiction list based on prices: Mininam Price: 43.0 Marinum Price: 53.0 Sorting comedy list based on prices: Mininam Price: 29.0 Marimam Price: 45.0 Sorting thriller list based on prices: Mininum Price: 23.0 Maxinam Drice: 47.0

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions