Answer to Question #8817 in C++ for zane

Question #8817
Write a function calculateItemCost prototyped by double calculateItemCost(double itemPrice, char discountType, unsigned quantity); so that the execution of this function will return the price for quantity number of the item priced originally at itemPrice each, and currently discounted according to discountType. For instance, calculateItemCost(10.90, &#039;D&#039;, 2) will return 17.44 because 17.44=10.9*0.8*2. Likewise calculateItemCost(5.50, &#039;B&#039;, 4) will return the value 19.8=5.50*0.9*4.
double calculateItemCost(double itemPrice, char discountType[], unsigned quantity){

double price;

price = itemPrice*quantity;

if (strcmp(discountType,&quot;A&quot;)==0) price *= 0.95;
if (strcmp(discountType,&quot;B&quot;)==0) price *= 0.9;
if (strcmp(discountType,&quot;C&quot;)==0) price *= 0.85;
if (strcmp(discountType,&quot;D&quot;)==0) price *= 0.8;

return price;

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!