Answer:
// program that implement the algorithm to find the change.
#include <bits/stdc++.h>
using namespace std;
// main function
int main()
{
// variables
int cost,q,d,n,p;
cout<<"Enter the cost of item between 25 cents and a dollar, in 5 increments (25, 30, 35, … , 90, 95, or 100):";
// read the cost
cin>>cost;
// find the change
int change=100-cost;
// find quarter
q=change/25;
change=change%25;
// find the dimes
d=change/10;
change=change%10;
// find the nickels
n=change/5;
// find the pennies
p=change%5;
// print the change
cout<<"Your change is: "<<q<<" quarter,"<<d<<" dimes,"<<n<<" nickels and "<<p <<" pennies."<<endl;
return 0;
}
Step-by-step explanation:
Read the cost of item from user and assign it to variable "cost".Then find the change to be returned to user.Then find the quarter by dividing the change with 25.Update the change and then find the dimes by dividing change with 10.Then update the change and find nickels and then find the pennies.Print the change to be returned.
Output:
Enter the cost of item between 25 cents and a dollar, in 5 increments (25, 30, 35, … , 90, 95, or 100):45
Your change is: 2 quarter,0 dimes,1 nickels and 0 pennies.