Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Book {
- String title;
- String author;
- double price;
- public Book(String title, String Author_Name,double Price)
- {
- setTitle(title);
- setAuthor(author);
- setPrice(price);
- }
- public void setTitle(String title)
- {
- this.title=title;
- }
- public void setAuthor(String author)
- {
- this.author=author;
- }
- public void setPrice(double price)
- {
- this.price=price;
- }
- public String getTitle()
- {
- return title;
- }
- public String getAuthor()
- {
- return author;
- }
- public double getPrice()
- {
- return price;
- }
- public String Book_details()
- {
- return ("Title :"+title+"\nAuthor :"+author+"\nprice :"+price);
- }
- public static void main(String args[])
- {
- Scanner in= new Scanner(System.in);
- String tt,aa;double pp;
- System.out.println("enter the book title :");
- tt=in.nextLine();
- System.out.println("enter the book author :");
- aa=in.nextLine();
- System.out.println("enter the book price :");
- pp=in.nextDouble();
- Book bk=new Book(tt,aa,pp);
- System.out.println("************ the book details are***************");
- System.out.println(bk.Book_details());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement