Question
The dollar change remaining after an amount paid is used to pay a restaurant bill of amount check can be calculated using the following C
The dollar change remaining after an amount paid is used to pay a restaurant bill of amount check can be calculated using the following C statements:
/* determine the amount of pennies in the change */
change = (paid - check) * 100;
/* determine the number of dollars in the change */
dollars = change / 100;
Using the previous statements as a starting point, write a C program that calculates the number of dollar bills, quarters, dimes, nickels, and pennies in the change when $10 is used to pay a bill of $6.07.
Explanation:
change = (paid check) * 100 /* The change in pennies */
change = 10-6.07 = $3.93
change in pennies = 3.93 * 100 = 393 pennies
int dollarBills = change / 100
dollarBills = 393/100 = 3 dollar bills
change = change dollarBills * 100 ( remaining change after removing dollar bills)
change = 393 300 = 93 pennies
int quarters = change / 25
quarters = 93/25 = 3 quarters
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started