The Peterman Publishing Company has decided that no published book should cost more than 10 cents per page. Create a BookException class whose constructor requires three arguments: a string Book title, a double price and an int number of pages. Create an error message that is passed to the Exception class constructor for the [I]message[I] property when a Book does not meet the price-to-pages ratio. For example an error message might be:


For Goodnight Moon,raio is incalid
...Price is $12.99 for 25 pages

Create a Book class that contains fields for title, author, price , and number of pager. Include properties for each fields. Throw a BookException if a client program tries to construct a Book object for which the price is more than 10 cents per page. Create a program that creates at least four Book objects- some were the ration is acceptable and the others where it is not. Catch any thrown exceptions and display the BookException Message.

To solve this problem, we need to implement two classes: `BookException` and `Book`.

First, let's create the `BookException` class with its required constructor and error message.

```java
public class BookException extends Exception {
public BookException(String message) {
super(message);
}
}
```

Next, let's create the `Book` class with the specified fields and properties. We'll throw a `BookException` if the price-to-pages ratio exceeds the allowed limit of 10 cents per page.

```java
public class Book {
private String title;
private String author;
private double price;
private int numberOfPages;

public Book(String title, String author, double price, int numberOfPages) throws BookException {
if (price / numberOfPages > 0.10) {
throw new BookException("Invalid price-to-pages ratio for " + title + ":\nPrice is $" + price + " for " + numberOfPages + " pages");
}

this.title = title;
this.author = author;
this.price = price;
this.numberOfPages = numberOfPages;
}

public String getTitle() {
return title;
}

public String getAuthor() {
return author;
}

public double getPrice() {
return price;
}

public int getNumberOfPages() {
return numberOfPages;
}
}
```

Finally, let's create a program that demonstrates the usage of the `Book` class and catches any thrown `BookException` to display the error message.

```java
public class Main {
public static void main(String[] args) {
try {
Book book1 = new Book("Goodnight Moon", "Author 1", 12.99, 25);
Book book2 = new Book("Book 2", "Author 2", 0.99, 100);
Book book3 = new Book("Book 3", "Author 3", 6.99, 50);
Book book4 = new Book("Book 4", "Author 4", 20.99, 200);
} catch (BookException e) {
System.out.println(e.getMessage());
}
}
}
```

In the `main` method, we create four `Book` objects. `book1` will throw a `BookException` because the price-to-pages ratio is invalid. We catch this exception and print the error message. The other three books have acceptable price-to-pages ratios and will be created successfully.

You can now run the program to see the output and validate the error message for the invalid book.