Menu
Question Index
...

Write a method to give 20% discount on the book price. The book will be passed as a parameter and the price has to be changed to reflect the discount. In the price was 100.0, it should become 80.0, if it was 70.0, it should become 56.0.



class DiscountBookPrice
{
    public static void main(String s[])
    {
        Book java = new Book();
        java.name = "Java The Complete Reference";
        java.author = "Herbert Schildt";
        java.edition = 7;
        java.numberOfPages = 1116;
        java.price = 600.0;
        
        discountBookPrice(java);
        
        System.out.println("The price of the book " + java.name + " after discount is Rs. " + java.price );

    }


    public static void discountBookPrice(Book input)
    {
    }

}
class Book
{
    String name;
    String author;
    int edition;
    int numberOfPages;
    double price;
}

Doubts

Problems

Topic: Class References And Objects In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App