Menu

[Solved]Java Please Program 1 Two Files Required Data Class Named Book Executable Class Named Test Q37072479

In JAVA ONLY PLEASE!

Program 1

Two files are required, a data class named Bookand an executable class named TestBook.

Class Book

  • has instance data members (all private) Stringtitle, String author, intpages, double price.
  • has a public static int variable namednumBooks with an initial value of zero.
  • has a parameterized constructor that will beused to make a Book object and assign values to its data members,and increment numBooks.
  • has a no-arg constructor that incrementsnumBooks.
  • has getters and setters forall instance data members.
  • has a toString() method that returns a stringdisplaying the state of a Book instance.
  • Use the numBooks variable to report the numberof books instantiated.

Class TestBook
This class needs a main method and two more methods.
In main:

  1. create an array capable of holding six Bookobjects.
  2. use the parameterized constructor to specifythe data in the first four elements of thisarray
  3. use the no-arg constructor to create thetwo remaining books in the array.
  4. process the array with a foreach loop todisplay the array at this point.
  5. call the finishArray() method with the arrayas the only argument.
  6. call the reduceBooks() method with the arrayas the sole argument.
  7. repeat the code needed by Step 4 above.
  8. display the most expensive book after the discounts.

In finishArray():

  1. this is a void method.
  2. use the setter methods to specify the data inall fields of the last two books in the array.

In reduceBooks():

  1. this method returns a Book instance.
  2. use a loop (any type) to reduce the price of every bookin the array by 40%.
  3. determine the most expensive book after thediscounts and return this book to main.

Book title-Java Programming, author=Liang, pages-1320, price = $145.00 Book title-Horton Hears a Who, author-Or . Seuss, pag

Book title-Java Programming, author=Liang, pages-1320, price = $145.00 Book title-Horton Hears a Who’, author-Or . Seuss, pages=72, price = $19.99 Book title-The Hobbit, author-Tolkien, pages 320, price -$9.25 Book title-Born a Crime, author=Noah, pages-304, price = $17.33 Book title-null, author-null, pages-0, price $0.00 Book title-null, author-null, pages-0, price -$0.00 Books after completing library and 40% discount Book title-Java Programming, author=Liang, pages=1320, price $87.00 Book title-Horton Hears a Who’, author-Or . Seuss, pages=72, price = $11.99 Book title-The Hobbit, author-Tolkien, pages 320, price -$5.55 Book title-Born a Crime, authorNoah, pages 304, price -$10.40 Book title-Dark Territory, author-Kaplan, pages-352, price-$11.24 Book title-Born to Run, author-Springsteen, pages:508, price $12.17 Here is the most expensive book after the discounts Book title-Java Programming, author Liang, pages-1320, price-$87.00 Size of library: 6 books Show transcribed image text Book title-Java Programming, author=Liang, pages-1320, price = $145.00 Book title-Horton Hears a Who’, author-Or . Seuss, pages=72, price = $19.99 Book title-The Hobbit, author-Tolkien, pages 320, price -$9.25 Book title-Born a Crime, author=Noah, pages-304, price = $17.33 Book title-null, author-null, pages-0, price $0.00 Book title-null, author-null, pages-0, price -$0.00 Books after completing library and 40% discount Book title-Java Programming, author=Liang, pages=1320, price $87.00 Book title-Horton Hears a Who’, author-Or . Seuss, pages=72, price = $11.99 Book title-The Hobbit, author-Tolkien, pages 320, price -$5.55 Book title-Born a Crime, authorNoah, pages 304, price -$10.40 Book title-Dark Territory, author-Kaplan, pages-352, price-$11.24 Book title-Born to Run, author-Springsteen, pages:508, price $12.17 Here is the most expensive book after the discounts Book title-Java Programming, author Liang, pages-1320, price-$87.00 Size of library: 6 books

Expert Answer


Answer to In JAVA ONLY PLEASE! Program 1 Two files are required, a data class named Book and an executable class named TestBook. C… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *