Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

What do you consider your major communication strengths?

Answered: 1 week ago

Question

10-9 How have social technologies changed e-commerce?

Answered: 1 week ago

Question

Understand how to design effective service guarantees.

Answered: 1 week ago

Question

Know when firms should not offer service guarantees.

Answered: 1 week ago