/*
 * Challenge 4
 * Find change for a given amount of cents
 */

#include <iostream>

using namespace std;

int main () {
    
    int cents {0};
    
    cout << "Enter an amount in cents: ";
    cin  >> cents;
    
    int dollars {0};    
    int quarters {0};
    int dimes {0};    
    int nickels {0};    
    int pennies {0}; 
    
    cout << "\n\nYou can provide this change as follows:\n";
    
    dollars = (cents - (cents % 100)) / 100;
    cents -= dollars * 100;
    
    quarters = (cents - (cents % 25)) / 25;
    cents -= quarters * 25;
 
    dimes = (cents - (cents % 10)) / 10;
    cents -= dimes * 10; 
    
    nickels = (cents - (cents % 5)) / 5;
    cents -= nickels * 5;
    
    pennies = (cents - (cents % 1)) / 1;
    cents -= pennies * 100;
    
    cout << "\n\nDollars:     " << dollars;
    cout << "\nQuarters:    " << quarters;
    cout << "\nDimes:       " << dimes;
    cout << "\nNickels:     " << nickels;
    cout << "\nPennies:     " << pennies;
    
    cout << "\n\n";
    
    return 0;
    
}

    // Edit
    // I knew I wasn't quite doing this right, what I should have done instead was something like this:
  
    // New variable to track the remaining balance
    int balance = 0;
    
    dollars = cents / 100;      // To get the number of dollars
    balance = cents % dollars;  // To get the remaining balance
    
    // say, we enter 90 cents then 90 / 100 = 0 (.90 but with integer math we just get 0) for our dollar count
    // balance then equals 90 MOD 100 which is 90 (the value we started with)
    
    // From here on out we now use balance instead of cents
    quarters = balance / 25;    // To get the number of quarters
    balance %= 25;              // To get the remaining balance
    
    // The remaining balance is now 90 MOD 25 which is 15 and we also at the same time have quarters stored as 3 for our count
    
    // Again, I knew I wasn't doing this in quite the best way.
    // I ended up doing a combination of using MOD but still doing calculation on the balance.
    // Good learning exercise
