Part C Code a do while loop to make change for a customer In
Solution
#include <iostream>
using namespace std;
void makePurchase()
 {
 float money;
 cout << \"Enter amount of money put into vending machine : \";
 cin >> money;
float purchase_money;
 cout << \"Enter amount of purchase : \";
 cin >> purchase_money;
int amount = (int)(money*100);
 int purchase = (int)(purchase_money*100);
int change = amount - purchase;
 if (change < 0)
 {
 cout << \"Purchase should be less than amount.\" << endl;
 return;
 }
if (change > 0)
 {
 cout << \"Change is: \";
 }
int quarters = change/25;
 change = change % 25;
int dimes = change / 10;
 change = change % 10;
int nickel = change / 5;
 change = change % 5;
int pennies = change;
 if (quarters > 0)
 {
 cout << quarters << \" quarters \";
 }
if (dimes > 0)
 {
 cout << dimes << \" dimes \";
 }
if (nickel > 0)
 {
 cout << nickel << \" nickels \";
 }
if (pennies > 0)
 {
 cout << pennies << \" pennies \";
 }
 }
int main()
 {
 char choice;
 do
 {
 makePurchase();
 cout << \"make more change (y/n): \";
 cin >> choice;
 } while(choice == \'y\');
}


