#include <iostream>
int main() {
const int DOLLAR = 100 , HALF_DOLLAR = 50 ,
QUARTER = 25 , DIME = 10 , NICKEL = 5 ,
PENNY = 1;
int price = 0 , paid = 0; //int not double
int number_dollar = 0 , number_half = 0 ,
number_quarter = 0 , number_dime = 0 ,
number_nickel = 0 , number_penny = 0 ,
change = 0;
std::cout << "Please enter the price(cents): ";
std::cin >> price;
std::cout << "Please enter what you paid(cents): ";
std::cin >> paid;
change = paid - price; //dont need to convert to dollars anymore
number_dollar = change / DOLLAR;
change %= DOLLAR;
number_half = change / HALF_DOLLAR;
change %= HALF_DOLLAR;
number_quarter = change / QUARTER;
change %= QUARTER;
number_dime = change / DIME;
change %= DIME;
number_nickel = change / NICKEL;
change %= NICKEL;
number_penny = change / PENNY;
change %= PENNY;
std::cout << "Dollars - " << number_dollar << std::endl
<< "Half - " << number_half << std::endl
<< "Quarter - " << number_quarter<< std::endl
<< "Dime - " << number_dime << std::endl
<< "Nickel - " << number_nickel << std::endl
<< "Penny - " << number_penny << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKaW50IG1haW4oKSB7Cgljb25zdCBpbnQgRE9MTEFSID0gMTAwICwgSEFMRl9ET0xMQVIgPSA1MCAsCgkJCSAgUVVBUlRFUiA9IDI1ICwgRElNRSA9IDEwICwgTklDS0VMID0gNSAsCgkJCSAgUEVOTlkgPSAxOwoJaW50IHByaWNlID0gMCAsIHBhaWQgPSAwOyAvL2ludCBub3QgZG91YmxlCglpbnQgbnVtYmVyX2RvbGxhciA9IDAgLCBudW1iZXJfaGFsZiA9IDAgLAoJICAgIG51bWJlcl9xdWFydGVyID0gMCAsIG51bWJlcl9kaW1lID0gMCAsCgkJbnVtYmVyX25pY2tlbCA9IDAgLCBudW1iZXJfcGVubnkgPSAwICwKCQljaGFuZ2UgPSAwOwoJCglzdGQ6OmNvdXQgPDwgIlBsZWFzZSBlbnRlciB0aGUgcHJpY2UoY2VudHMpOiAiOwoJc3RkOjpjaW4gPj4gcHJpY2U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