Question: JAVA For this assignment, you will write a program that simulates a bookstore database. You will need to implement 3 classes Media.java (an abstract class)

JAVA For this assignment, you will write a program that simulates a bookstore database.

You will need to implement 3 classes

Media.java (an abstract class)

Book.java (subclass of Media.java)

TwiceSoldTales.java (bookstore)

Make a new project folder in Eclipse to store the above 3 classes

You will also be working with an input file of data about some books.

Next, place a new textfile named books.txt into your project folder, and copy and paste the below data into this file:

The Time in Between Maria Duenas 9.86 43-453-44 2 Bleak House Charles Dickens 8.99 35-678-97 4 Rebecca Daphe Dumaurier 5.50 32-423-82 5 A Room with a View E.M. Forster 7.50 11-778-89 3 Outlander Diana Galbadon 19.95 54-665-65 7 Jane Eyre Charlotte Bronte 7.90 23-456-74 4 The Hunger Games Suzanne Collins 6.90 42-323-22 10 The Woman in White Wilkie Collins 10.75 32-567-89 2 A Face like Glass Frances Hardinge 15.95 44-554-43 1 Lady Audley's Secret Mary Elizabeth Braddon 5.50 12-121-34 1 Murder on the Orient Express Agatha Christie 2.99 98-375-83 8 Middlemarch George Elliot 12.50 12-567-43 4 Our Souls at Night Kent Haruf 11.99 78-474-89 2 Fangirl Rainbow Rowell 10.79 24-137-25 6 Ramona Blue Julie Murphy 9.99 93-283-11 4 The Rosie Project Graeme Simsion 14.99 82-389-31 5 A is for Alibi Sue Grafton 4.55 34-323-21 3 Still Life Louise Penny 18.99 33-443-22 5 Flight Behavior Barbara Kingsolver 9.98 56-382-34 4

Next, copy and paste the below starter code into your files and implement the methods according to the comments provided.

Media.java:

Please do not add any new methods to this class. Instead, implement the provided methods.

public abstract class Media { private String title; private double price; private int numCopies; /** * Default constructor for the Media * class. Calls the three argument * constructor, passing in "title unknown", * 0.0 and 0 */ public Media() { } /** * Constructor for the Media class * @param title the media title * @param price the sale price * @param numCopies the number of copies * currently in stock */ public Media(String title, double price, int numCopies) { } /** * Returns the title of the media * @return the title */ public String getTitle() {

return "";

} /** * Returns the price of the media * @return the price */ public double getPrice() {

return 0.0;

} /** * Returns the current number of * copies available * @return the number of copies */ public int getNumCopies() {

return 0;

} /** * Returns whether there are more than * 0 copies of the media * @return whether any copies are * available to purchase */ public boolean availableToPurchase() { } /** * Sets the price to be a new price * @param price the price of the media */ public void setPrice(double price) { } /** * Determines how to increase the price * each time a copy gets sold (and media * gets rarer) */ public abstract void updatePrice(); /** * Decrements the number of copies * when a media gets sold */ public void decreaseCopies() { } }

Book.java:

Note, consult the Oracle documentation on DecimalFormat for more information.

Please do not add any new methods to this class. Instead, implement the provided methods.

import java.text.DecimalFormat; public class Book extends Media { private String author; private String isbn; private static int numBooks = 0; /** * Default constructor for Book. * Calls the 2 argument constructor * Sets title default to "title unknown" * Sets author default to "author unknown" */ public Book() { } /** * Two argument constructor for the Book * class. Calls the 5 argument constructor * Sets price to a default of 0.0, * isbn to a default of "0" and numCopies * to a default of 0 * @param title the book's title * @param author the book's author */ public Book(String title, String author) { } /** * Constructor for book. Calls media constructor * @param title the book's title * @param author the book's author * @param price the book's price * @param isbn the book's 7-digit isbn * @param numCopies the current num copies */ public Book(String title, String author, double price, String isbn, int numCopies) { } /** * Returns the first and last names * of the author * @return the author */ public String getAuthor() {

return "";

} /** * Returns the 7 digit ISBN number * @return the ISBN number */ public String getISBN() {

return "";

} /** * Returns the total number of books * @return the value of numBooks */ public static int getNumBooks() {

return 0;

} /** * Increases the price of the book by * $0.25 each time a copy is sold */ public void updatePrice() { } /** * Updates numBooks variable by * a specified amount * @param n the number of books to add */ public static void updateNumBooks(int n) { } /** * Overrides equals for Object using the * formula given in class. For the purposes * of this assignment, we will consider * two books to be equal on the basis of * title and author only * @return whether two books have the same * title and author */ @Override public boolean equals(Object o) {

return false;

} /** * Creates a book String in the following format * Title: * Author: <author> * Price: $<price to two decimal places> * ISBN #: <isbn> * Copies: <numcopies> * Note that there are no <> around the values * The <> are standard in programming * to indicate fill in here */ @Override public String toString() { DecimalFormat df = new DecimalFormat("#.##"); return " Price: $" + df.format(getPrice()); } }</p> <p> </p> <p> <strong><strong>TwiceSoldTales.java:</strong></strong></p> <p> </p> <p>Please add any additional methods to this class that you find necessary, in addition to implementing those that have been provided.</p> <p> import java.util.ArrayList; import java.util.Scanner; import java.io.File; import java.io.IOException; public final class TwiceSoldTales { private ArrayList<book> books = new ArrayList<book>(); private static final String filename = "books.txt"; /** * Inserts books from file into the books ArrayList * @param input the Scanner * @throws IOException */ private void populateCatalogue(Scanner input) throws IOException { } /** * Searches for a specific book in the * ArrayList of books. Compares them * using the equals method defined in Book.java * @param b the book to search for * @return the location of the book in the * ArrayList or -1 to indicate not found */ private int linearSearch(Book b) { return -1; } public static void main(String[] args) throws IOException { TwiceSoldTales t = new TwiceSoldTales(); String title, author, isbn; File file = new File(filename); Scanner input = new Scanner(file);</p> <p> input.close();</p> <p> } }</p> <p><strong><strong>Sample Output</strong><strong>:</strong></strong></p> <p> </p> <p>Welcome to Twice Sold Tales! We currently have 80 books in stock! Looking for a specific book? Enter the book information below: Title: Bleak House Author: Charles Dickens We have Bleak House in stock! Title: Bleak House Author: Charles Dickens Price: $8.99 ISBN #: 35-678-97 Copies: 4 Would you like to purchase it (y/n): y Thank you for your purchase! Updated entry for this book: Title: Bleak House Author: Charles Dickens Price: $9.24 ISBN #: 35-678-97 Copies: 3</p> <p> </p> <p> <strong><strong><strong><strong><strong><strong>Sample Output</strong><strong>:</strong></strong></strong></strong></strong></strong></p> <p> </p> <p>Welcome to Twice Sold Tales! We currently have 80 books in stock! Looking for a specific book? Enter the book information below: Title: Dombey and Son Author: Charles Dickens Sorry! We don't carry that title right now. Goodbye!</p> </div> <div class="question-answer-divider"></div> <section class="answerHolder" itemscope itemtype="http://schema.org/Answer"> <div class="answerHolderHeader"> <h2>Step by Step Solution</h2> <div class="answerReviews"> <div class="starIcon"> </div> </div> </div> <div class="questionProperties"> <p>There are 3 Steps involved in it</p> <div class="cart-flex"> <div class="cart cart1"> 1 Expert Approved Answer </div> </div> </div> <div class="step org_answer"> <span class="view_solution_btn view-solution-btn-cursor"> <strong class="step-heading step-1">Step: 1 <span>Unlock <i class="fa-solid fa-lock"></i></span></strong> </span> <img src="https://www.solutioninn.com/includes/images/document_product_info/blur-text-image.webp" class="blured-ans-image" width="759" height="271" alt="blur-text-image" decoding="async" fetchpriority="high"> <div class="step1Popup"> <span class="heading">Question Has Been Solved by an Expert!</span> <p>Get step-by-step solutions from verified subject matter experts</p> <button class="view_solution_btn step1PopupButton">View Solution</button> </div> </div> <div class="step"> <span class="view_solution_btn view-solution-btn-cursor"> <strong class="accordion step-heading">Step: 2 <span>Unlock <i class="fa-solid fa-lock"></i></span></strong> </span> </div> <div class="step"> <span class="view_solution_btn view-solution-btn-cursor"> <strong class="accordion step-heading">Step: 3 <span>Unlock <i class="fa-solid fa-lock"></i></span></strong> </span> </div> </section> <section class="relatedQuestion"> <h3>Students Have Also Explored These Related Databases Questions!</h3> <div class="relatedQuestionSliderHolder"> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/write-a-program-in-java-that-simulates-a-bookstore-database-714159" > write a program in JAVA that simulates a bookstore database. You will need to write 3 classes Media.java (an abstract class) Book.java (subclass of Media.java) TwiceSoldTales.java (bookstore) Also,... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/a-discrete-sequence-xn-can-be-converted-into-a-continuous-17790729" > A discrete sequence {xn} can be converted into a continuous representation x(t) = ts X n= (t n ts) xn, where ts is the sampling period. (a) State two characteristic properties of Dirac's function. [2... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/please-finishfix-the-code-so-that-it-will-compile-and-12563077" > PLEASE FINISH/FIX THE CODE SO THAT IT WILL COMPILE AND RUN IN CODING ROOMS IDE WITHOUT ISSUES. THANK YOU!!! PLEASE FINISH/FIX THE CODE SO THAT IT WILL COMPILE AND RUN IN CODING ROOMS IDE WITHOUT... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/please-fix-my-code-so-it-will-compile-and-the-12437656" > PLEASE FIX MY CODE SO IT WILL COMPILE AND THE PROGRAM WILL RUN PROPERLY. THANK YOU SO MUCH!!! PLEASE FIX MY CODE SO IT WILL COMPILE AND THE PROGRAM WILL RUN PROPERLY. THANK YOU SO MUCH!!! Book.java... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/please-fix-my-code-so-it-will-compile-in-coding-12412133" > PLEASE FIX MY CODE SO IT WILL COMPILE IN CODING ROOMS WITHOUT ERRORS!!! PLEASE FIX MY CODE SO IT WILL COMPILE IN CODING ROOMS WITHOUT ERRORS!!! Book.java package bookStore; public class Book extends... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/please-fix-my-code-so-that-it-will-compile-without-12377252" > PLEASE FIX MY CODE SO THAT IT WILL COMPILE WITHOUT ERRORS. THANK YOU!!! PLEASE FIX MY CODE SO THAT IT WILL COMPILE WITHOUT ERRORS. THANK YOU!!! Book.java package bookStore; public class Book extends... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/starter-code-step-2-identification-comments-go-here-12602070" > Starter code // STEP 2: IDENTIFICATION COMMENTS GO HERE // STEP 2: THE IMPORT STATEMENTS GO HERE public class FLast_Lab05 // STEP 2: CHANGE THIS TO MATCH YOUR FILE NAME { public static void... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/i-need-to-solve-this-assignment-with-the-java-language-7096154" > I need to solve this assignment with the java language please Assignment Objective and Description: By the completion of this assignment you should be able to: - Write map-reduce jobs in Java... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/learning-objectives-edit-compile-and-run-java-programs-utilize-arrays-13800828" > Learning objectives Edit, compile and run Java programs Utilize arrays to store information Apply basic object-oriented programming concepts Understand the university policies for academic integrity... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/im-very-lost-on-how-to-proceed-with-this-project-13812654" > I'm very lost on how to proceed with this project, any help would be greatly appreciated. This is a Java project. Programming Assignment 5 -Java Identifier Parser Note: When you turn in an assignment... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/evaluate-the-limit-y-8xy-lim-8x-108669" > Evaluate the limit. y - 8xy lim - 8x (.) (6,48) - 8xy Find an expression that is equal to f(x,y) = for all (x,y) in the domain of f, that will be better suited to y- 8x find the limit, if it... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/if-the-total-tared-mass-of-a-tin-oxide-formed-41982" > If the total tared mass of a tin oxide formed in an experiment weighs 0.703 grams and it contains 0.544 g of Sn (formula weight = 118.7 amu), calculate the amount of oxygen it contains and determines... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/pportunity-costs-are-not-found-in-accounting-records-because-they-27956830" > pportunity costs are not found in accounting records because they are not relevant to decisio True False </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/questions/seved-help-14-wisconsin-snowmobile-corp-is-considering-a-switch-15204872" > Seved Help 14 Wisconsin Snowmobile Corp. is considering a switch to level production Cost efficiencies would occur under level production, and aftertax costs would decline by $31,500, but inventory... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/principles-of-macroeconomics/2-how-does-selfinterest-help-achieve-societys-economic-goals-why-2126695" > 2. How does self-interest help achieve societys economic goals? Why is there such a wide variety of desired goods and services in a market system? In what way are entrepreneurs and businesses at the... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/principles-of-macroeconomics/8-with-current-technology-suppose-a-firm-is-producing-400-2126701" > 8. With current technology, suppose a firm is producing 400 loaves of banana bread daily. Also, assume that the least-cost combination of resources in producing those loaves is 5 units of labor, 7... </a> </div> <div class="relatedQuestionCart "> <p class="heading">Q: </p> <a class="relatedQuestionText" href="/study-help/principles-of-macroeconomics/7-in-the-1990s-thousands-of-dotcom-companies-emerged-with-2126700" > 7. In the 1990s thousands of dot-com companies emerged with great fanfare to take advantage of the Internet and new information technologies. A few, like Yahoo, eBay, and Amazon, have generally... </a> </div> </div> <nav class="navigationButtons"> <a class="previousQuestionButton" href="/study-help/questions/c-need-help-on-operator-overloading-in-a-class-13429241">Previous Question</a> <a class="nextQuestionButton" href="/study-help/questions/for-python-task-1-polynomials-draw-graphs-in-the-13429243">Next Question</a> </nav> </section> </main> <aside class="expertRight"> <section class="relatedBook" style="margin-bottom:40px; width: 100%;" > <div class="bookHolder" > <div class="relatedBookHeading" > <h2 class="heading">Recommended Textbook</h2> </div> <div class="bookMainInfo" > <div class="bookImage" style="width: 100px !important; min-width: 100px; flex-shrink: 0; margin-right: 20px;"> <a href="/textbooks/the-database-experts-guide-to-database-2-1st-edition-9780070232679"> <img src="https://dsd5zvtm8ll6.cloudfront.net/si.question.images/book_images/65097ad74572d_55611.jpg" width="100" height="131" alt="The Database Experts Guide To Database 2" loading="lazy" style="width: 100px !important;"> </a> <a href="/textbooks/computer-science-windows-server-2766" style="margin-top: 8px; display: block; text-align: left;">More Books</a> </div> <div class="bookInfo" style="text-align: left;"> <span class="bookTitle" style="text-align: left;"> <a href="/textbooks/the-database-experts-guide-to-database-2-1st-edition-9780070232679" style="text-align: left;"> The Database Experts Guide To Database 2 </a> </span> <div class="bookMetaInfo" style="text-align: left;"> <p class="bookAuthor" style="text-align: left;"> <b>Authors:</b> <span>Bruce L. Larson</span> </p> <p class="bookEdition" style="text-align: left;"> 1st Edition </p> <p class="bookEdition" style="text-align: left;"> 0070232679, 978-0070232679 </p> </div></div></div> </div> </section> <div class="post-question-section"> <div class="description-question-section"> <span class="post-question-section-title">Ask a Question and Get Instant Help!</span> </div> <div class="text-area-post-question"> <form action="/study-help/post-question?ref=search" method="post" enctype="multipart/form-data"> <textarea rows="4" class="form-control form-posting-margin" name="textarea-question-content" id="textarea-question-content" placeholder="Type Your Question ...."></textarea> <button type="submit" class="btn btn-sm btn-submit-post-question text-center">Get Answer</button> </form> </div> </div> </aside> </div> </div> <div class="promo items-center justify-center hidden"> <div class="app_promo"> <span class="app_promo_dismiss"> <i class="fa-solid fa-x"></i> </span> <div class="app-button"> <div class="image-wrapper"> <img width="30" height="30" src="https://www.solutioninn.com/includes/images/rewamp/common/mobile-app-logo.png" decoding="async" fetchpriority="high" alt="SolutionInn App Logo"> <strong>Study Help</strong> </div> <button class="app_promo_action redirection" data-question-open-url='q_id=13429242&q_type=2'> Open in App </button> </div> </div> </div> </div> </div> <div class="blank-portion"></div> <footer> <div class="container footerHolder"> <div class="footerLinksFlex"> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-6"> <p>Services</p> <ul> <li><a href="/site-map">Sitemap</a></li> <li><a href="/fun/">Fun</a></li> <li><a href="/study-help/definitions">Definitions</a></li> <li><a href="/tutors/become-a-tutor">Become Tutor</a></li> <li><a href="/books/used-textbooks">Used Textbooks</a></li> <li><a href="/study-help/categories">Study Help Categories</a></li> <li><a href="/study-help/latest-questions">Recent Questions</a></li> <li><a href="/study-help/questions-and-answers">Expert Questions</a></li> <li><a href="/clothing">Campus Wear</a></li> <li><a href="/sell-books">Sell Your Books</a></li> </ul> </div> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-6"> <p>Company Info</p> <ul> <li><a href="/security">Security</a></li> <li><a href="/copyrights">Copyrights</a></li> <li><a href="/privacy">Privacy Policy</a></li> <li><a href="/conditions">Terms & Conditions</a></li> <li><a href="/solutioninn-fee">SolutionInn Fee</a></li> <li><a href="/scholarships">Scholarship</a></li> <li><a href="/online-quiz">Online Quiz</a></li> <li><a href="/study-feedback">Give Feedback, Get Rewards</a></li> </ul> </div> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-6"> <p>Get In Touch</p> <ul> <li><a href="/about-us">About Us</a></li> <li><a href="/support">Contact Us</a></li> <li><a href="/career">Career</a></li> <li><a href="/jobs">Jobs</a></li> <li><a href="/support">FAQ</a></li> <li><a href="https://www.studentbeans.com/en-us/us/beansid-connect/hosted/solutioninn" target="_blank" rel="noopener nofollow">Student Discount</a></li> <li><a href="/campus-ambassador-program">Campus Ambassador</a></li> </ul> </div> <div class="footerLinksCol col-md-3 col-lg-3 col-sm-6 col-12"> <p>Secure Payment</p> <div class="footerAppDownloadRow"> <div class="downloadLinkHolder"> <img src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/rewamp/common/footer/secure_payment_method.png" class="img-fluid mb-3" width="243" height="28" alt="payment-verified-icon" loading="lazy"> </div> </div> <p>Download Our App</p> <div class="footerAppDownloadRow"> <div class="downloadLinkHolder mobileAppDownload col-md-6 col-lg-6 col-sm-6 col-6 redirection" data-id="1"> <img style="cursor:pointer;" src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/rewamp/home_page/google-play-svg.svg" alt="SolutionInn - Study Help App for Android" width="116" height="40" class="img-fluid mb-3 " loading="lazy"> </div> <div class="downloadLinkHolder mobileAppDownload col-md-6 col-lg-6 col-sm-6 col-6 redirection" data-id="2"> <img style="cursor:pointer;" src="https://dsd5zvtm8ll6.cloudfront.net/includes/images/rewamp/home_page/apple-store-download-icon.svg" alt="SolutionInn - Study Help App for iOS" width="116" height="40" class="img-fluid mb-3" loading="lazy"> </div> </div> </div> </div> </div> <div class="footer-bottom"> <p>© 2026 SolutionInn. All Rights Reserved</p> </div></footer> <script> window.addEventListener("load",function(){jQuery(document).ready(function(t){ // Clarity tracking (function(c,l,a,r,i,t,y){ c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)}; t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i; y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y); })(window, document, "clarity", "script", "sjv6tuxsok"); // Helper to read a cookie by name function getCookie(name) { return document.cookie .split('; ') .map(v => v.split('=')) .reduce((acc, [k, val]) => (k === name ? decodeURIComponent(val || '') : acc), ''); } // Read cookies var si = getCookie('si_u_id'); var uid = getCookie('u_id'); var zen = getCookie('zenid'); // Send to Clarity if (si) clarity('set', 'si_u_id', si); if (uid) clarity('set', 'u_id', uid); if (zen) clarity('set', 'zenid', zen); clarity('set', 'ip_address', '216.73.216.134'); t.ajax({type:"POST",url:"/",data:{trackUserActivity:!0,reqUri:document.URL,referer:document.referrer},success:function(t){}})})},!1),window.addEventListener("load",function(){jQuery(document).ready(function(t){t.ajax({type:"POST",url:"/",data:{insertCrawler:!0,reqUri:document.URL,parseTime:"0.056",queryTime:"0.01654768548584",queryCount:"30"},success:function(t){}})})},!1),window.addEventListener("load",function(){jQuery(document).ready(function(){function t(t="",n=!1){var i="itms-apps://itunes.apple.com/app/id6462455425",e="openApp://action?"+t;isAndroid()?(setTimeout(function(){return window.location="market://details?id=com.solutioninn.studyhelp",!1},25),window.location=e):isIOS()?(setTimeout(function(){return window.location=i,!1},25),window.location=e):(i="https://apps.apple.com/in/app/id6462455425",n&&(i="https://play.google.com/store/apps/details?id=com.solutioninn.studyhelp"),window.open("about:blank","_blank").location.href=i)}jQuery("#appModal").modal("show"),jQuery(".download-app-btn").click(function(){t(jQuery(this).attr("data-question-open-url"))}),jQuery(".redirection").click(function(){var n=jQuery(this).attr("data-question-open-url"),i=jQuery(this).attr("data-id");void 0!=n?1==i?t(n,!0):t(n,!1):1==i?t("",!0):t("",!1)}),jQuery(".app-notification-close").click(function(){jQuery(".app-notification-section").css("visibility","hidden");var t=new FormData;t.append("hide_notification",!0),jQuery.ajax({type:"POST",url:"/",data:t,cache:!1,contentType:!1,processData:!1,beforeSend:function(){},success:function(t){location.reload()}})})})},!1); </script> </body> </html>