Creating a book class and displaying book details

Report a typo

Create a class named 'Book' with a title, author, and number of pages, and provide methods to set and get these data. Next, in your main function, create a new 'Book' instance and set the title and author as inputted from user input and set the number of pages to 100. Finally, print the book details in the following format: 'Title:

, Author: <author>, Pages: 100'.</author>

Sample Input 1:

To Kill a Mockingbird
Harper Lee

Sample Output 1:

Title: To Kill a Mockingbird, Author: Harper Lee, Pages: 100

Sample Input 2:

1984
George Orwell

Sample Output 2:

Title: 1984, Author: George Orwell, Pages: 100
Write a program in Java 25
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String title = sc.nextLine();
String author = sc.nextLine();
Book book = new Book();

// Set the details of the book
// Implement here

// Print the details of the book
// Implement here
}
}

class Book {
private String title;
private String author;
private int pages;

// Getters and setters
// Implement here
}

Create a free account to access the full topic