Advertisement
Vladkoheca

book.java

Nov 22nd, 2024
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | Source Code | 0 0
  1. public class Book {
  2.  
  3.     public String title;
  4.     public String author;
  5.     public double price;
  6.  
  7.     public Book(String title, String author, double price){
  8.         this.title = title;
  9.         this.author = author;
  10.         this.price = price;
  11.     }
  12.  
  13.     public double applyDiscount(double discount){
  14.          return price - (price*discount/100);
  15.  
  16.     }
  17.  
  18.     public void displayBook(){
  19.         System.out.println("The title of the book is : " + title);
  20.         System.out.println("The author of the book is : " + author);
  21.         System.out.println("The price of the book is : " + price);
  22.  
  23.     }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement