Write a program to create a class Book with the following
attributes: -isbn, title, author, price
methods : i. Initialize the data members through parameterized constructor
ii. displaydeta ils() to display the details of the book
iii. discountedprice() : pass the discount percent, calculate the discount on price and find the amount to be paid after discount
task : Create an object book, initialize the book and display the details along with the discounted price.
---------------------------------------------------------------------------------------------------------------------------
public class Test {
public static void main(String[] args) {
displaydetails();
discountedprice();
}
public static void displaydetails() {
Book bookinvoke = new Book(1234, "Core Java", "JavaCodeAuthor", 500);
System.out.println("Isbn="+bookinvoke.isbn +"\nTitle="+ bookinvoke.title +"\nAuthor="+ bookinvoke.author +"\nPrice="+ bookinvoke.price);
}
public static void discountedprice() {
int discountpercent=10;
int discountedprice= 500*discountpercent/100;
int finalamount=500-discountedprice;
System.out.println("final amount="+finalamount);
}
}
class Book {
int isbn;
String title;
String author;
int price;
Book(int isbn, String title, String author, int price) {
this.isbn = isbn;
this.title = title;
this.author = author;
this.price = price;
}
}