Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a Eclipse Java project. The project must contain a class BookCreater.java . It must have EXACTLY the same content as follows: import java.util.ArrayList; import

Create a Eclipse Java project. The project must contain a class BookCreater.java. It must have EXACTLY the same content as follows:

import java.util.ArrayList;

import java.util.Scanner;

public class BookCreater {

public static void main(String[] args) { Scanner input = new Scanner(System.in); String entry;

System.out.print("Enter title of a book or \"q\" to quit >> "); entry = input.nextLine(); while (!entry.equals("q")) { String title = entry; System.out.print("How many authors >> "); int numAuthors = Integer.parseInt(input.nextLine()); ArrayList authors = new ArrayList(); for (int i = 0; i < numAuthors - 1; i++) { System.out.print("Author #" + (i + 1) + " >> "); authors.add(input.nextLine()); } System.out.print("Author #" + numAuthors + " >> "); authors.add(input.nextLine()); System.out.print("Enter the price >> "); double price = Double.parseDouble(input.nextLine()); CommercialBook book = new CommercialBook(title, authors, price); System.out.println(book); book.save(); System.out.print("Enter title of a book or \"q\" to quit >> "); entry = input.nextLine(); } System.out.println("Bye!");

}

}

Study the above code carefully and then create another class CommercialBook.java in the same project. The CommercialBook.java may contain any methods, but MUST contain the following instance variables ONLY:

- String title;

- ArrayList authors;

- double price;

When running the program (i.e., main method in BookCreater.java), the program will get the title, authors and price of a book from user, then save the record in the MS Access DB file CSIS2175002Quiz02.accdb. The following shows a sample run of the program (Green text refers to user input):

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: 3

blur-text-image

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

Students also viewed these Databases questions