cpp1_code_f07 - USERNAME _ NAME _ 1. (30 pts) A company...

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

View Full Document Right Arrow Icon
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); }
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/05/2011 for the course CGS 2421 taught by Professor Onal during the Fall '09 term at University of Florida.

Page1 / 3

cpp1_code_f07 - USERNAME _ NAME _ 1. (30 pts) A company...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online