Advertisement
Arnab_Manna

bookass7.java

Dec 11th, 2021
1,017
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. import java.util.*;
  2. public class Book {
  3.     String title;
  4.     String author;
  5.     double price;
  6.    
  7.     public Book(String title, String Author_Name,double Price)
  8.     {
  9.         setTitle(title);
  10.         setAuthor(author);
  11.         setPrice(price);
  12.     }
  13.    
  14.     public void setTitle(String title)
  15.     {
  16.         this.title=title;
  17.     }
  18.     public void setAuthor(String author)
  19.     {
  20.         this.author=author;
  21.     }
  22.     public void setPrice(double price)
  23.     {
  24.         this.price=price;
  25.     }
  26.     public String getTitle()
  27.     {
  28.         return title;
  29.     }
  30.     public String getAuthor()
  31.     {
  32.         return author;
  33.     }
  34.     public double getPrice()
  35.     {
  36.         return price;
  37.     }
  38.     public String Book_details()
  39.     {
  40.        return ("Title :"+title+"\nAuthor :"+author+"\nprice :"+price);
  41.     }
  42.     public static void main(String args[])
  43.     {
  44.         Scanner in= new Scanner(System.in);
  45.         String tt,aa;double pp;
  46.         System.out.println("enter the book title :");
  47.         tt=in.nextLine();
  48.         System.out.println("enter the book author :");
  49.         aa=in.nextLine();
  50.         System.out.println("enter the book price :");
  51.         pp=in.nextDouble();
  52.        
  53.         Book bk=new Book(tt,aa,pp);
  54.         System.out.println("************ the book details are***************");
  55.         System.out.println(bk.Book_details());
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement