104k views
0 votes
Allyson is making an online store. Her code needs to calculate the final cost of a $32 item with a $5 coupon applied.

The initial code looks like this:
itemsCost ← 32
coupon amount ← 5
Which code successfully calculates and stores the final cost?
A. finalCost ← itemCost MOD couponAmount
B. finalCost ← itemCost / couponAmount
C. finalCost ← itemCost + (-1 * couponAmount)
D. finalCost ← (couponAmount - itemCost)
E. finalCost ← (itemCost - couponAmount)
F. finalCost ← itemCost - couponAmount

User Xueli
by
8.4k points

1 Answer

1 vote

The correct code to calculate and store the final cost after applying a $5 coupon to a $32 item is: E. finalCost ← (itemCost - couponAmount)

How to explain

This code subtracts the coupon amount from the item cost, reflecting the deduction of the $5 coupon from the initial item price.

It results in the final cost after applying the discount, providing Allyson with the accurate amount customers would pay for the item after the coupon is applied.

The correct code to calculate and store the final cost after applying a $5 coupon to a $32 item is: E. finalCost ← (itemCost - couponAmount)

User Diceyus
by
7.7k points