Question: Please use java to solve. Please do not use arrays, I have not gotten to that chapter yet. Thank you. 1. Define a class named

 Please use java to solve. Please do not use arrays, I

Please use java to solve. Please do not use arrays, I have not gotten to that chapter yet. Thank you.

1. Define a class named Book that contains: An int data field named pages that stores the number of pages of the book A String data field named title that represents the title of the book . A constructor with parameters for initializing pages and title The getter and setter methods for all data A toString method that returns book information, including the book title and the number of pages The equals method that returns true if two books have the same title and the same number of pages. . The compareTo method that compares two books and returns -1 if the first book has less pages than the second one, 1 if the first book has more pages than the second one, and 0 if both books have same number of pages as the second one. 2. Write an application TestBooks that asks the user repeatedly for books read during summer (use a sentinel value to control the end of input). The application repeatedly creates book objects, and then prints to the screen information about the smallest" book, (i.e. the book with the smallest number of pages), as well as the average number of pages per book HINT: This program MUST make use of the compareTo method in order to find the "smallest" book

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!