109k views
0 votes
Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Assuming the item is paid for with a minimum amount of change and just single dollars, write an expression for the amount of change (in cents) that would have to be paid.

User JohanSJA
by
6.4k points

1 Answer

5 votes

Answer:


Change = (Paid*100) - Price

Explanation:

First of all we need to know the relation between 1 dollar and 1 cent in order to express everything in the units required in the question.

We know that
1 dollar = 100 cents
, so the amount paid for the item with single dollars has to be multiplied by 100 to express its value in cents.


Paid_(cents)=Paid_(dollars)*100

Now that we have everything in cents, we can make the subtraction:


Change_(cents) = Paid_(cents) -Price_(cents)

Replacing the value in cents we get:


Change = (Paid*100) - Price

User Konstantinos
by
6.1k points