Question: Create a Book class with attributes author(String), title (String), and price (String). Make sure you create ALL modifiers and accessors, and a toString that will
Create a Book class with attributes author(String), title (String), and price (String). Make sure you create ALL modifiers and accessors, and a toString that will print the author, the title, and the price. Create a compareTo that will compare according to the title.
You have been given an input file called book.txt In the input file there are three lines for each book The author is on the first line, the title on the second line, and the price on the third line. Write a program to create an arrayList that will hold Book objects, Get input from the file,create Book objects and put them into the arrayList. Output the arrayList IN REVERSE. Then call Collections sort. Output the arrayList again, this time NOT in reverse. Note: You have been given two input files. You don't know which one we shall use for grading. Verify your program works with both by just altering the name of the file in your try/catch.
include comments
Thanks in advance! :D thumbs up for answers as always


Book files:
book 1:

Book2:

package test2num2; import java.io.File; import java.io.FileNotFoundException; import java.util.*; public class Test2Num2 { public static void main(String[] args) { Scanner fileInput=null; File f = new File("book.txt"); try fileInput new Scanner (f); } catch (FileNotFoundException e) { } }//main }//class package test2num2; public class Book { } book - Notepad File Edit Format View Help Beck Pascal: A guided Tour $34.59 Stallings Computer Security $76.99 Hartley Concurrent Programming $45.00 Warford Computer Systems $34.00 *** Ford Data Structures with C++ $39.99 Roberts Thinking Recursively $35.50 Ln 1, Col 1 100% Windows (CRLF) UTF-8 book2 - Notepad File Edit Format View Help Savitch Java: Problem Solving and Programming $139.95 Liang Introduction to Java Programming $97.00 Gaddis Starting Out With Java $120.00 Beck Pascal: A guided Tour $34.59 Stallings Computer Security $76.99 Hartley Concurrent Programming $145.00 Warford Computer Systems $134.00 Ford Data Structures with C++ $39.99 Roberts Thinking Recursively $65.50
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
