Write a program that directs a cashier how to give change Th

Write 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. Display the dollars, quarters, dime nickels, and pennies that the customer should receive.

Solution

#include <iostream>

using namespace std;

int main()
{
int amountDue, received;
cout << \"Enter the amount due: \";
cin >> amountDue;
cout<<\"Enter the amount received from customer: \";
cin >> received;
if(amountDue - received > 0){
cout<<\"Received amount should be greater than the amount Due\"<<endl;
}
else{
int change = received - amountDue;
int quarters;
int dimes;
int nickels;
int pennies;
int dollors;
dollors = change / 100;
change = change % 100;
quarters = change / 25;
change = change % 25;
dimes = change / 10;
change = change % 10;
nickels = change / 5;
change = change % 5;
pennies = change;
cout<<\"*****************Change to give**********\"<<endl;
cout<<\"dollors: \"<<dollors<<endl;
cout<<\"quarters: \"<<quarters<<endl;
cout<<\"dimes: \"<<dimes<<endl;
cout<<\"nickels: \"<<nickels<<endl;
cout<<\"pennies: \"<<pennies<<endl;
}

return 0;
}

Output:

sh-4.2$ g++ -o main *.cpp                                                                                                                                                                                                                                              

sh-4.2$ main                                                                                                                                                                                                                                                           

Enter the amount due: 301                                                                                                                                                                                                                                              

Enter the amount received from customer: 500                                                                                                                                                                                                                           

*****************Change to give**********                                                                                                                                                                                                                              

dollors: 1                                                                                                                                                                                                                                                             

quarters: 3                                                                                                                                                                                                                                                            

dimes: 2                                                                                                                                                                                                                                                               

nickels: 0                                                                                                                                                                                                                                                             

pennies: 4

 Write 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. Display the do
 Write 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. Display the do

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site