I need help with this program. Please!!!

Can someone help guide me in the right direction? honestly, I have no idea where to start. Here's the question.

Giving change. Implement a program that directs a cashier how to
give change. The program has two inputs: the amount due and the amount received
from the customer. It should compute the difference, and compute the dollars,
quarters, dimes, nickels, and pennies that the customer should receive in return.
Hint: First transform the difference into an integer balance, denominated in pennies.
Then compute the whole dollar amount. Subtract it from the balance. Compute
the number of quarters needed. Repeat for dimes and nickels. Display the
remaining pennies.

Any help would be greatly appreciated. Thanks!
Last edited on
here's what i have so far


#include <iostream>

using namespace std;

int main ()
{
cout << "Enter amount due." << endl;

double due;

double received;

cin >> due;

cout << "Enter amount received." << endl;

cin >> received;

double difference = due - received;

int change = static_cast<int>(difference + 0.5);

const int PENNIES_PER_DOLLAR = 100;

change = change % PENNIES_PER_DOLLAR;



cout << change << endl;

return 0;
Topic archived. No new replies allowed.