Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Question #2 40 points a) Create an abstract class DiscountPolicy. It should have a single abstract method computeDiscount that will return the discount from

Java
image text in transcribed
Question #2 40 points a) Create an abstract class DiscountPolicy. It should have a single abstract method computeDiscount that will return the discount from the purchase of a given number of a single item. The method has two parameters, count and itemcost. b) Derive a class BuyNItemsGetoneFree from Discount Policy. It should have a constructor that has a single parameter n. The data member of this class will be n. In addition, the class should define the method computeDiscount so that every nth item is Eree. For example, if n is 3 and the customer buys 7 items and the cost of each item is $10, then the discount will be $20 since every 3rd item will be tree. It n is 4 and the cost of each item is $10 and if the user buys 7 items, then the discount will be $10. c) Create testing class 20 point

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

Students also viewed these Databases questions