Function call in expression: Reduced pricing
Write a single statement that assigns totalCost with the discounted cost of item 1 and item 2. Use the function DiscountedPrice to determine the discounted cost of each item. Hint: Call DiscountedPrice() twice in an expression. Ex: If the first item is $10 and 50% off, and the second item is $20 and 40% off, then totalCost is $17 (i.e. $5 + $12).
Discounted Price is already provided:
function saleltemCost Discounted Price (originalItemCost, discountedRate)
originalItemCost: Original cost of an item in dollars
discountedRate: Discount rate as a decimal value
saleltemCost = originalItemCost * (1 – discountedRate)
end
Your Solution
Save C Reset MATLAB Documentation
function totalCost = CartTotal(item1Cost, item1Discount, item2Cost, item2Discount)
Assign total cost with the discounted cost of items 1 and 2
totalCost = DiscountedPrice(item1Cost, item1Discount) + DiscountedPrice(item2Cost, item2Discount)
end
Leave a Reply