// Zeinalipour-Yazti Demetrios // csyiazti // cs10xx - // Lab Sec#24 // lab1 /* Simple "Customer Change Program" The program allows the user to enter the amount of the change in cents. It then calculates and print out how many quarters, dimes, nickels, and pennies, should be given back to fulfill this amount of change. The program tries to give as many higher value coins as possible. */ #include using namespace std; void main() { /* declaration of variables */ int amount; // the amount (in cents) given by the user int quarters; // the calculated quarters (to return) int dimes; // the calculated dimes (to return) int nickels; // the calculated nickels (to return) int pennies; // the calculated pennies (to return) // get amount (in cents) from user cout << "Please enter the amount of change (in cents): "; cin >> amount; // output initial amount of cents cout << "For : " << amount << " cents, you should return :\n"; // calculate quarters & calculate remaining cents quarters = amount / 25; amount = amount % 25; // calculate quarters & calculate remaining cents dimes = amount / 10; amount = amount % 10; // calculate nickels & calculate remaining pennies nickels = amount / 5; pennies = amount % 5; // output results if (quarters==1) { cout << quarters << " quarter\n"; } else { cout << quarters << " quarters\n"; } if (dimes==1) { cout << dimes << " dime \n"; } else { cout << dimes << " dimes \n"; } if (nickels==1) { cout << nickels << " nickel \n"; } else { cout << nickels << " nickels \n"; } if (pennies==1) { cout << pennies << " penny \n"; } else { cout << pennies << " pennies \n"; } }