COMPLETED CLASS: public class Book { private String title; private String isbn; private int qty;…


public class Book {

private String title;
private String isbn;
private int qty;
private double price;
private boolean isForSale;
public Book (String t, String i, int q, double p)
public Book()
title = “title”;
isbn = “isbn”;
qty = 0;
price = 0.0;
isForSale = false;
//set Methods
public void setTitle(String t)
title = t;
public void setISBN(String i)
isbn = i;
public void setQty(int q)
qty = q;
public void setPrice(double p)
price = p;
public void setIsForSale(boolean s)
isForSale = s;
public String getTitle()
return title;
public String getISBN()
return isbn;
public int getQty()
return qty;
public double getPrice()
return price;
public boolean isForSale()
return isForSale;
/** The equals methods compares the data that belongs to 2 Rectangle objects to see if they’re equal */
public boolean equals (Book book2)
if ((this.title.equals(book2.title)) && (this.isbn.equals(book2.isbn)) )
return (true);
return (false);
/** The toString method prints the data that belongs to an object */
public String toString()
return (title + isbn + qty + price + isForSale);



import java.util.Scanner;
public class BobsBookStore {

public static Scanner scan = new Scanner(;
public static void main(String[] args) throws IOException
// create a file object for the file “BobsBooks.txt”
File file = new File (“BobsBooks.txt”);
// create a Scanner object to read from the file BobsBooks.txt
Scanner inputFile = new Scanner(file);
// create an array of 20 book objects
final int book = 20;
// use a while loop to read the contents of the file “BobsBooks.txt” while there is more data to read
while (inputFile.hasNext())
String bookName =;
int isbn = inputFile.nextInt();
int bookQuantity = inputFile.nextInt();
double bookPrice = inputFile.nextDouble();
// read the the data values for each book and use this data to create a book object,
// store it in the array books
// close the file “BobsBooks.txt”
while (!done);
System.out.println(“*** Welcome To Bobs Books ***”);
System.out.println(“*** We Sell Books At Discounted Prices ***n”);
System.out.println(” How can we help you? (choose an option)”);
System.out.println(” 1. Search for a book by Title or ISBN”);
System.out.println(” 2. Buy a book”);
System.out.println(” 3. Backup Inventory and quit”);
//write a do loop to verify a valid option was entered, repeat while incorrect values entered
// print a message ” enter option: “
// if the option entered is not 1, 2, or 3
// print a message “Invalid choice, try again…”
switch (option)
case 1: searchByTitleOrISBN(books);
case 2: buyBook(books);
case 3: backupBooks(books);
System.out.println(“Program Ended…”);
done = true;
System.out.println(“Invalid choice, try again…”);
//This method will search the books array for a given book
//If the book is found by title or isbn, and the quantity > 0, and it’s for sale, it returns the array index of the book
// otherwise, it returns a -1
public static int searchByTitleOrISBN(Book[] b)
// print a message “Enter the Title or ISBN of the book: “
System.out.println(“Enter the Title or ISBN of the books: “);
// use a while loop to search through the array books using a counter and as long as no match is found
while (ISBN)
// if there’s a match for the title or a match for the isbn and the book quantity > 0 and the book is for sale
// print a message “We have that book in stock and it is available for purchase!!”
// print column headers ” Title ISBN Quantity Price For Sale”
// print the information for the book (call method toString())
// indicate a match was found
// otherwise,
// increase counter i
// if a match was found,
// return the array index of the book
// otherwise,
// print a message “Sorry, we do not have that book in stock or it not for sale.”
// return -1 (code for book not found, or not in stock, or not for sale)
return -1;
//This method will process the purchase of a book
public static void buyBook(Book[] b)
// call the method searchByTitleOrISBN to see if the book is in stock and for sale
// if so,
// print a message “The price is $(value)”
// print a message “Do you wish to purchase it? (y or n): “
// if so,
// print a message “Great, the total with tax is $(value)” (format with printf, tax is 6.25%)
// print a message “Thank you for your purchase!”
// print a message “Have a good day!”
// update the quantity for this book
// otherwise,
// print a message “Okay maybe another time.”
// print a message “Have a good day!”
//This method will write the contents of the book inventory (array) to the file “BobsBooks.txt”
public static void backupBooks(Book[] b) throws IOException
// create a PrintWriter object to rewrite the file “BobsBooks.txt”
// use a for loop to write the information for each book in the array books to the file “BobsBooks.txt (call method toString())

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
The price is based on these factors:
Academic level
Number of pages
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
error: Content is protected !!