Imagine a publishing company that markets both Book and CD's of its works. A class Publication is created that stores the title (a string) and price (type int) of a publication. From this class derive two classes:

Each of these two classes should have a putdata() function to display its data as shown in sample output.

Sample Input

Programming-In-C		// Titleof Book
150				// Priceof Book
1025				// Pagesof Book
Schildt				// Writerof Book
Rock-On			// Titleof CD
50				// Priceof CD
185					// Lengthof CD

Sample Output

Book Title "Programming-In-C", writtenby "Schildt" has 1025 pagesandof 150 rupees.
CD Title "Rock-On",isof 185 minutes lengthandof 50 rupees.
class Book extends Publication {
    int pageCount;
    String author;
    // Constructor for Book class
    Book(String title, int price, int pageCount, String author) {
        // Directly initialize the inherited fields without calling super()
        this.title = title;
        this.price = price;
        this.pageCount = pageCount;
        this.author = author;
    }
    // Method to display book details
    void putdata() {
        System.out.println("Book Title \\"" + title + "\\", written by \\"" + author + "\\" has " + pageCount + " pages and of " + price + " rupees.");
    }
}
class CD extends Publication {
    int playingTime;
    // Constructor for CD class
    CD(String title, int price, int playingTime) {
        // Directly initialize the inherited fields without calling super()
        this.title = title;
        this.price = price;
        this.playingTime = playingTime;
    }
    // Method to display CD details
    void putdata() {
        System.out.println("CD Title \\"" + title + "\\", is of " + playingTime + " minutes length and of " + price + " rupees.");
    }
}