#include #include using namespace std; /* algorithm Ask for cost pennies Ask for cost flakies Ask for cost buckies Covert these to pennies, penniesOwed ask for paid pennies ask for paid flakies ask for paid buckies Convert these to pennies, penniesPaid Calculate change = penniesPaid - penniesOwed Convert cost to optimal and print find the buckies costBuckies = penniesOwed / PENNIES_PER_BUCKIE penniesOwed = penniesOwed % PENNIES_PER_BUCKIE find the flakies costFlakies = penniesOwed / PENNIES_PER_FLAKIE penniesOwed = penniesOwed % PENNIES_PER_FLAKIE repeat this process for penniesPaid repeat this process for change */ const int PENNIES_PER_FLAKIE{11}; const int FLAKIES_PER_BUCKIE{7}; const int PENNIES_PER_BUCKIE{PENNIES_PER_FLAKIE * FLAKIES_PER_BUCKIE}; int main() { int costPennies, costFlakies, costBuckies; int penniesOwed; int paidPennies, paidFlakies, paidBuckies; int penniesPaid; int changePennies, changeFlakies, changeBuckies; int penniesChange; cout << "Enter the pennies term of the cost => "; cin >> costPennies; cout << "Enter the flakies term of the cost => "; cin >> costFlakies; cout << "Enter the buckies term of the cost => "; cin >> costBuckies; penniesOwed = costPennies + costFlakies * PENNIES_PER_FLAKIE + costBuckies * PENNIES_PER_BUCKIE; costPennies = penniesOwed; costBuckies = costPennies / PENNIES_PER_BUCKIE; costPennies = costPennies % PENNIES_PER_BUCKIE; costFlakies = costPennies / PENNIES_PER_FLAKIE; costPennies = costPennies % PENNIES_PER_FLAKIE; cout << "The actual cost was:" << endl; cout << setw(20) << costBuckies << " buckies" << endl; cout << setw(20) << costFlakies << " flakies" << endl; cout << setw(20) << costPennies << " pennies" << endl; return 0; }