Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started