Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 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.

include comments

Thumbs up for answers :D. Thanks in advance.

Book files:

book1:

image text in transcribed

book2: image text in transcribed

image text in transcribed

image text in transcribed

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 package test2numl; import java.io.File; import java.io.FileNotFoundException; import java.util.*; public class Test2Num1 { 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 test2numl; 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_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

4. Who would lead the group?

Answered: 1 week ago

Question

Where those not participating, encouraged to participate?

Answered: 1 week ago