Question: I want the answer Question 4 (23+5 Points) Part (1) Define a class with the following specifications: a. The class name is Book with three
Question 4 (23+5 Points) Part (1) Define a class with the following specifications: a. The class name is Book with three private data members: title (String), price (double), and discountVoucherNo (int). b. Write a constructor that accepts title, price and discountVoucherNo as input parameters to initializes the private data members. c. Provide an accessor (get) method and a mutator (set) method only for the discountVoucherNo data member. d. Define a private method called isVoucherMatched( ) that returns true if an integer voucher number passed to the method matches the object's discountVoucherNo, otherwise, it should returns false. e. Define a public method called show( ) that requests the user to input a discount voucher and calls the isVoucherMatched() method. The method should display the book title and price (with discount if applicable). If the call to isVoucherMatched( ) method returned true, it should display the price as a discounted value ( 15% less) else the price should be displayed as it is. See Sample Below Question 4 (23+5 Points) Part (1) Define a class with the following specifications: a. The class name is Book with three private data members: title (String), price (double), and discountVoucherNo (int). b. Write a constructor that accepts title, price and discountVoucherNo as input parameters to initializes the private data members. c. Provide an accessor (get) method and a mutator (set) method only for the discountVoucherNo data member. d. Define a private method called isVoucherMatched( ) that returns true if an integer voucher number passed to the method matches the object's discountVoucherNo, otherwise, it should returns false. e. Define a public method called show( ) that requests the user to input a discount voucher and calls the isVoucherMatched() method. The method should display the book title and price (with discount if applicable). If the call to isVoucherMatched( ) method returned true, it should display the price as a discounted value ( 15% less) else the price should be displayed as it is. See Sample Below
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
