
Given below is a class definition for Book. Type and compile the class, and answer the following questions:
class Book { String title; //bookâ??s title double price; //bookâ??s price
public Book(String t, double p) { title = t; price = p; } public String getTitle() { return title; }
public double getPrice() { return price; } }
Write a program in a class TestBook that can do the following:
Read an integer, n (representing the number of books), from the keyboard and then create an array name myLibrary of type Book with size n.
Using loop, create n objects of type Book and put them in the array myLibrary after reading the title and price for each book from the keyboard.
Print out the title of the book with the highest price.
Print out all titles of books that contain the term â??Javaâ?? in their title.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.