76 311
Assignments Done
Successfully Done
In May 2019

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.
Expert's answer
double calculateItemCost(double itemPrice, char discountType[], unsigned quantity){

double price;

price = itemPrice*quantity;

if (strcmp(discountType,"A")==0) price *= 0.95;
if (strcmp(discountType,"B")==0) price *= 0.9;
if (strcmp(discountType,"C")==0) price *= 0.85;
if (strcmp(discountType,"D")==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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions