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 author's name.
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 array that will hold a maximum of TEN Book objects, this means your array is of length 10. Get input from the file,create Book objects and put them into the array. Output the array 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 Tnum1 {
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
Get step-by-step solutions from verified subject matter experts
