107 325
Assignments Done
98.9%
Successfully Done
In March 2023

# 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, 'D', 2) will return 17.44 because 17.44=10.9*0.8*2. Likewise calculateItemCost(5.50, 'B', 4) will return the value 19.8=5.50*0.9*4.
1
2012-04-28T09:42:56-0400
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!