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

Veröffentlicht am: 03 Februar 2020
auf dem Kanal: 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;
}
}


Auf dieser Seite können Sie das Online-Video Java program to create a class Book with the following - attributes: - methods : - task :. mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Basic Code 03 Februar 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 13,099 Mal angesehen und es wurde von 91 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!