import java.util.Scanner;
class publisher1 {
String publisherName;
int publisherId;
public void getData() {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter Publisher Name: ");
publisherName = scanner.nextLine();
System.out.print("Enter Publisher ID: ");
publisherId = scanner.nextInt();
}
public void showData() {
System.out.println("Publisher Name:" + publisherName);
System.out.println("Publisher ID: " + publisherId);
}
}
class Book extends publisher {
String bookName;
int bookId;
String authorName;
public void getData() {
super.getData();
Scanner scanner = new Scanner(System.in);
System.out.print("Enter Book Name: ");
bookName = scanner.nextLine();
System.out.print("Enter Book ID: ");
bookId = scanner.nextInt();
scanner.nextLine(); // Consume the new line character
System.out.print("Enter Author Name: ");
authorName = scanner.nextLine();
}
public void showData() {
super.showData();
System.out.println("Book Name: " + bookName);
System.out.println("Book ID: " + bookId);
System.out.println("Author Name: " + authorName);
}
}
public class publisher {
public static void main(String[] args) {
Book book = new Book();
book.getData();
book.showData();
}
public void showData() {
}
public void getData() {
}
}
Top comments (0)