So, the point of this assignment is to get the change for the customer in the exact quarters, dimes, nickels, and pennies. I have already calculated how to get the total change and everything. I feel like I have done how to get that exact change. I think think the only problem right now is changing the double to int for how many dollars, quarters, dimes, etc. that is needed (because you can't split coins, etc.) I know that static_cast<int> should be used, but I'm not quite sure how to use it. Here's what I have:
#include <iostream>
using namespace std;
int main()
{
double purchase_amount;
double receive_amount;
double total_change;
double dollars;
double quarters;
double dimes;
double nickels;
double pennies;
cout << "Enter purchase amount: ";
cin >> purchase_amount;
cout << "Enter amount received: ";
cin >> receive_amount;
total_change = receive_amount - purchase_amount;
cout << "Total change: " << total_change;
dollars = total_change % 1;
cout << "Dollars: " << endl;
total_change = total_change - dollars * 1;
quarters = total_change % .25;
cout << "Quarters: " << endl;
total_change = total_change - quarters * .25;
dimes = total_change % .10;
cout << "Dimes: " << endl;
total_change = total_change - dimes * .10;
nickels = total_change % .05;
cout << "Nickels: " << endl;
total_change = total_change - nickels * .05;
pennies = total_change % .01;
cout << "Pennies: " << endl;
return 0;
}