{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cpp1_code_f07

# cpp1_code_f07 - USERNAME NAME 1(30 pts A company faces a...

This preview shows pages 1–2. Sign up to view the full content.

USERNAME ___________________ NAME __________________________________ 1. (30 pts) A company faces a fixed cost K dollars when it places an order. The unit cost of the product is C 1 if the order quantity is less than Q; otherwise the unit cost will be C 2 .In other words, the company will get a discounted price if it orders more units. The cost structure is shown below. Example: Given Q = 200, K = \$50, C1 = \$3/unit, C2 = \$2/unit, (A) 150 units are ordered, Cost = 50 + 3 × 150 = \$500. (B) 250 units are ordered, Cost = 50 + 2 × 250 = \$550. Write a function called totalCost() to compute the cost of an order. The prototype is given below: double totalCost( int x, double K, double C1, double C2, int Q); where x is the order quantity and the other arguments are as defined above. --------------------------------------------- Your Solution -------------------------------------------- double totalCost( int x, double K, double C1, double C2, int Q) { if ( x < Q ) return (K + C1*x); else return (K + C2*x); }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

cpp1_code_f07 - USERNAME NAME 1(30 pts A company faces a...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online