Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the attached data file, write a payload class Book that represents a book. The fields are id, title, publisher, type, price and paperback. Most

Given the attached data file, write a payload class Book that represents a book.

The fields are id, title, publisher, type, price and paperback. Most should be String fields, but price should be a double and paperback should be a boolean.

The one constructor should take a Scanner parameter opened to the file. It should input each of the fields using the Scanner. Note that for the paperback field, you should input a String, and set the field to true or false according to whether the String is "Y" or not.

The toString method should print out the title, type, price and paperback fields as in the sample output below. Use a DecimalFormat object to format the price, and print out "paperback" or "hardback" based on the value of the paperback field.

Write a drive in a separate file.

The driver should declare an ArrayList of Book objects and instantiate a Scanner for the attached books.txt, then use it to instantiate and add new books to the list as long as hasNextLine() is true for the Scanner. Then, print out each of the books.

A Deepness in the Sky (SFI) $7.19 paperback

Magic Terror (HOR) $7.99 paperback

The Stranger (FIC) $8.00 paperback

Venice (ART) $24.50 hardback

Second Wind (MYS) $24.95 hardback

The Edge (MYS) $6.99 paperback

Dreamcatcher: A Novel (HOR) $19.60 hardback

Treasure Chests (ART) $24.46 hardback

Beloved (FIC) $12.95 paperback

Harry Potter and the Prisoner of Azkaban (SFI) $13.96 hardback

Van Gogh and Gauguin (ART) $21.00 hardback

Of Mice and Men (FIC) $6.95 paperback

Electric Light (POE) $14.00 hardback

Group: Six People in Search of a Life (PSY) $10.40 paperback

Nine Stories (FIC) $5.99 paperback

The Soul of a New Machine (SCI) $11.16 paperback

Travels with Charley (TRA) $7.95 paperback

Catch-22 (FIC) $12.00 paperback

Jazz (FIC) $12.95 paperback

Band of Brothers (HIS) $9.60 paperback

A Guide to SQL (CMP) $37.95 paperback

Franny and Zooey (FIC) $5.99 paperback

East of Eden (FIC) $12.95 paperback

Harry Potter and the Goblet of Fire (SFI) $18.16 hardback

The Fall (FIC) $8.00 paperback

Godel Escher Bach (PHI) $14.00 paperback

When Rabbit Howls (PSY) $6.29 paperback

Black House (HOR) $18.81 hardback

Song of Solomon (FIC) $14.00 paperback

The Grapes of Wrath (FIC) $13.00 paperback

Slay Ride (MYS) $6.99 paperback

The Catcher in the Rye (FIC) $5.99 paperback

To Kill a Mockingbird (FIC) $18.00 hardback

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