Question
IN JAVA PLEASE Create a Book class with attributes author(String), title (String), and price (String). Make sure you create ALL modifiers and accessors, and a
IN JAVA PLEASE
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.
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){ } } }
public class Book { }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started