Java program to create a class Book with the following - attributes: - methods : - task :.

Published: 03 February 2020
on channel: Basic Code
13,099
91

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;
}
}


On this page of the site you can watch the video online Java program to create a class Book with the following - attributes: - methods : - task :. with a duration of hours minute second in good quality, which was uploaded by the user Basic Code 03 February 2020, share the link with friends and acquaintances, this video has already been watched 13,099 times on youtube and it was liked by 91 viewers. Enjoy your viewing!