1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Rama09 [41]
4 years ago
7

Create an abstract class DiscountPolicy. It should have a single abstract method computeDiscount that will return the discount f

or the purchase of a given number of a single item. The method has two parameters, count and itemCost. 2. Derive a class BulkDiscount from DiscountPolicy, as described in the previous exercise. It should have a constructor that has two parameters, minimum and percent. It should define the method computeDiscount so that if the quantity purchased of an item is more than minimum, the discount is percent percent. 3. Derive a class BuyNItemsGetOneFree from DiscountPolicy, as described in Exercise 1. The class should have a constructor that has a single parameter n. In addition, the class should define the method computeDiscount so that every nth item is free. For example, the following table gives the discount for the purchase of various counts of an item that costs $10, when n is 3: count 1 2 3 4 5 6 7 Discount 0 0 10 10 10 20 20
4. Derive a class CombinedDiscount from DiscountPolicy, as described in Exercise 1. It should have a constructor that has two parameters of type DiscountPolicy. It should define the method computeDiscount to return the maximum value returned by computeDiscount for each of its two private discount policies. The two discount policies are described in Exercises 2 and 3. 5. Define DiscountPolicy as an interface instead of the abstract class described in Exercise 1.
Engineering
1 answer:
eimsori [14]4 years ago
6 0

Answer:

Java Code was used to define classes in the abstract discount policy,The bulk discount, The buy items get one free and the combined discount

Explanation:

Solution

Code:

Main.java

public class Main {

public static void main(String[] args) {

  BulkDiscount bd=new BulkDiscount(10,5);

BuyNItemsGetOneFree bnd=new BuyNItemsGetOneFree(5);

CombinedDiscount cd=new CombinedDiscount(bd,bnd);

System.out.println("Bulk Discount :"+bd.computeDiscount(20, 20));

  System.out.println("Nth item discount :"+bnd.computeDiscount(20, 20));

 System.out.println("Combined discount :"+cd.computeDiscount(20, 20));    

  }

}

discountPolicy.java

public abstract class DiscountPolicy

{    

public abstract double computeDiscount(int count, double itemCost);

}    

BulkDiscount.java  

public class BulkDiscount extends DiscountPolicy

{    

private double percent;

private double minimum;

public BulkDiscount(int minimum, double percent)

{

this.minimum = minimum;

this.percent = percent;

}

at Override

public double computeDiscount(int count, double itemCost)

{

if (count >= minimum)

{

return (percent/100)*(count*itemCost); //discount is total price * percentage discount

}

return 0;

}

}

BuyNItemsGetOneFree.java

public class BuyNItemsGetOneFree extends DiscountPolicy

{

private int itemNumberForFree;

public BuyNItemsGetOneFree(int n)

{

  itemNumberForFree = n;

}

at Override

public double computeDiscount(int count, double itemCost)

{

if(count > itemNumberForFree)

return (count/itemNumberForFree)*itemCost;

else

  return 0;

}

}

CombinedDiscount.java

public class CombinedDiscount extends DiscountPolicy

{

private DiscountPolicy first, second;

public CombinedDiscount(DiscountPolicy firstDiscount, DiscountPolicy secondDiscount)

{

first = firstDiscount;

second = secondDiscount;

}

at Override

public double computeDiscount(int count, double itemCost)

{

double firstDiscount=first.computeDiscount(count, itemCost);

double secondDiscount=second.computeDiscount(count, itemCost);

if(firstDiscount>secondDiscount){

  return firstDiscount;

}else{

  return secondDiscount;

}

}  

}

You might be interested in
50POINTS
maxonik [38]

Answer:

Ensure that all material and energy inputs and outputs are as inherently safe and benign as possible. Minimize the depletion of natural resources. Prevent waste. Develop and apply engineering solutions while being cognizant of local geography, aspirations, and cultures.Green engineering is the design, commercialization, and use of processes and products that minimize pollution, promote sustainability, and protect human health without sacrificing economic viability and efficiency.The goal of environmental engineering is to ensure that societal development and the use of water, land and air resources are sustainable. This goal is achieved by managing these resources so that environmental pollution and degradation is minimized.

Explanation:i helped

7 0
3 years ago
Read 2 more answers
Two dogbone specimens of identical geometry but made of two different materials: steel and aluminum are tested under tension at
makkiz [27]

Answer:

\dot L_{steel} = 3.448\times 10^{-4}\,\frac{in}{min}

Explanation:

The Young's module is:

E = \frac{\sigma}{\frac{\Delta L}{L_{o}} }

E = \frac{\sigma\cdot L_{o}}{\dot L \cdot \Delta t}

Let assume that both specimens have the same geometry and load rate. Then:

E_{aluminium} \cdot \dot L_{aluminium} = E_{steel} \cdot \dot L_{steel}

The displacement rate for steel is:

\dot L_{steel} = \frac{E_{aluminium}}{E_{steel}}\cdot \dot L_{aluminium}

\dot L_{steel} = \left(\frac{10000\,ksi}{29000\,ksi}\right)\cdot (0.001\,\frac{in}{min} )

\dot L_{steel} = 3.448\times 10^{-4}\,\frac{in}{min}

7 0
3 years ago
Read 2 more answers
A manometer is used to measure the air pressure in a tanlc The fluid used has a specific gravity of 1.25, and the differentialhe
Alenkasestr [34]

Answer:

(a) 11.437 psia

(b) 13.963 psia

Explanation:

The pressure exerted by a fluid can be estimated by multiplying the density of the fluid, acceleration due to gravity and the depth of the fluid. To determine the fluid density, we have:

fluid density = specific gravity * density of water = 1.25 * 62.4 lbm/ft^3 = 78 lbm/ft^3

height = 28 in * (1 ft/12 in) = 2.33 ft

acceleration due to gravity = 32.174 ft/s^2

The change in pressure = fluid density*acceleration due to gravity*height = 78*32.174*(28/12) = 5855.668 lbm*ft/(s^2 * ft^2) = 5855.668 lbf/ft^2

The we convert from lbf/ft^2 to psi:

(5855.668/32.174)*0.00694 psi = 1.263 psi

(a) pressure = atmospheric pressure - change in pressure = 12.7 - 1.263 = 11.437 psia

(b) pressure = atmospheric pressure + change in pressure = 12.7 + 1.263 = 13.963 psia

8 0
3 years ago
Shane's 100-watt radio draws 7 amps of current on a 120-volt circuit. What is the resistance in the radio?
lawyer [7]

Answer:

Resistance, R = 2.04 Ohms.

Explanation:

Given the following data;

Current = 7 amps

Circuit voltage = 120 Volts

Power = 100 Watts

To find the resistance;

First of all, we would calculate the potential difference (voltage level) used by the radio.

Power = current * voltage

100 = 7 * voltage

Voltage = 100/7

Voltage = 14.29 Volts

Next, we solve for the resistance of the radio;

Ohm's law states that at constant temperature, the current flowing in an electrical circuit is directly proportional to the voltage applied across the two points and inversely proportional to the resistance in the electrical circuit.

Mathematically, Ohm's law is given by the formula;

V = IR

Where;

V represents voltage measured in voltage.

I represents current measured in amperes.

R represents resistance measured in ohms.

Substituting into the formula, we have;

14.29 = 7*R

R = \frac {14.29}{7}

Resistance, R = 2.04 Ohms.

7 0
3 years ago
The rate of flow through an ideal clarifier is 8000m3 /d, the detention time is 1h and the depth is 3m. If a full-length movable
Fittoniya [83]

Answer:

a) 35%

b) yes it can be improved by moving the tray near the top

   Tray should be located ( 1 to 2 meters below surface )

   max removal efficiency ≈ 70%

c) The maximum removal will drop as the particle settling velocity = 0.5 m/h

Explanation:

Given data:

flow rate = 8000 m^3/d

Detention time = 1h

depth = 3m

Full length movable horizontal tray :  1m below surface

<u>a) Determine percent removal of particles having a settling velocity of 1m/h</u>

velocity of critical sized particle to be removed = Depth / Detention time

= 3 / 1 = 3m/h

The percent removal of particles having a settling velocity of 1m/h ≈ 35%

<u>b) Determine if  the removal efficiency of the clarifier can be improved by moving the tray, the location of the tray  and the maximum removal efficiency</u>

The tray should be located near the top of the tray ( i.e. 1 to 2 meters below surface ) because here the removal efficiency above the tray will be 100% but since the tank is quite small hence the

Total Maximum removal efficiency

=  percent removal_{above} + percent removal_{below}

= ( d_{a},v_{p} ) . \frac{d_{a} }{depth}  + ( d_{a},v_{p} ) . \frac{depth - d_{a} }{depth}  = 100

hence max removal efficiency ≈ 70%

<u>c) what is the effect of moving the tray would be if the particle settling velocity were equal to 0.5m/h?</u>

The maximum removal will drop as the particle settling velocity = 0.5 m/h

7 0
3 years ago
Other questions:
  • A copper wire of original diameter .80 m exhibits a maximum tensile load/ strength at an engineering stress= 248.2 mpa. its duct
    11·1 answer
  • A well-insulated, rigid tank has a volume of 1 m3and is initially evacuated. A valve is opened,and the surrounding air enters at
    6·1 answer
  • Say you have a random, unordered list containing 4096 four-digit numbers. Describe the most efficient way to: sort the list and
    8·1 answer
  • Two hemispherical shells of inner diameter 1m are joined together with 12 equally spaced bolts. If the interior pressure is rais
    15·1 answer
  • Socket Programming: (30 points) Use Python TCP socket to implement an application with client-server architecture. In this appli
    12·1 answer
  • 4. Which of the following is the first thing you should do when attempting
    13·2 answers
  • Different metabolic control systems have different characteristic time scales for a control response to be achieved. Match the t
    6·1 answer
  • Pls help me with these 3 ez questions.
    8·2 answers
  • A _______ contact allows current to flow when the switch's operator is not activated.?
    6·1 answer
  • The sum of forces on node 2 (upper-left) is ______.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!