Consider a mail-order business in which customers get a discount based on the quantity they order. In writing a program to compute the discount based on a customer's order quantity, why is it not a good idea to construct an array with as many elements as a customer might want to order, and store the appropriate discount associated with each number?

What will be an ideal response?

This approach has at least three drawbacks:
• It requires a very large array that uses a lot of memory.
• You must store the same value repeatedly. For example, each of the first nine elements receives the same value, 0, and each of the next four elements receives the same value, 10.
• How do you know when you have enough array elements? Is a customer order quantity of 75 items enough? What if a customer orders 100 or 1,000 items? No matter how many elements you place in the array, there's always a chance that a customer will order more.

Computer Science & Information Technology

You might also like to view...

When a chart is selected, the Style and Color galleries can be displayed by clicking the ________ button that appears to the right of the chart

Fill in the blank(s) with correct word

Computer Science & Information Technology

Answer the following statements true (T) or false (F)

1. Concrete classes provide implementations for at least one of the methods and properties they define. 2. You may define implementations for abstract methods to act as a default. 3. All methods in an abstract class are abstract. 4. The MustOverride keyword has the same effect as the Overridable keyword. 5. Objects of abstract base classes can be instantiated.

Computer Science & Information Technology