Write a program that converts a monetary value to paper bills and coins. The user should be able to enter a floating
point value (e.g. 52.76) and the program should convert it to the minimum number of paper bills ($50 bills, $10 bills,
$1 bills) and coins (quarters 25¢, nickels 5¢ and penny 1¢) that can be used (e.g. for 50.76 you have 1 50$ bill, 3
quarters, 0 nickels and 1 penny). The program should use only the 3 types of paper bills and the 3 types of coins. Hint:
to make sure you use the minimum number of paper bills and coins, you should use as many $50 bills, then as many $10
bills, then as many dollar bills, then as many quarters, then as many nickels, and, in the end, pennies.
The program should read the monetary values, compute the number of paper bills and coins of each type, and output to
the console the number of paper bills and coins in the following English sentence format:
The change due is $52.76: 1 $50 bill(s), 0 $10 bill(s), 2 $1 bill(s), 3 quarter(s), 0
nickel(s), and 1 penny(ies).
So far this is what I have. I'm really new at this...
#include <stddef.h>#include <cassert>
#include <iostream>
using namespace std;
int main()
{
// Variable Declarations
double change;
int remainingChange;
int fifties;
int tens;
int ones;
int quarters;
int nickels;
int pennies;
// Prompt user for amount
cout << "How much change is due? ";
cin >> change;
cout << "\n";
// Convert to int by multiplying by 100 so mod (%) operator can be used
remainingChange = change * 100;
// Determine number of $50 bills and determine remaining change
fifties = remainingChange / 5000;
remainingChange = remainingChange % 5000;
// Determine number of $10 bills and determine remaining change
tens = remainingChange / 1000;
remainingChange = remainingChange % 1000;
// Determine number of $1 bills and determine remaining change
ones = remainingChange / 100;
remainingChange = remainingChange % 100;
// Determine number of quarters and determine remaining change
quarters = remainingChange / 25;
remainingChange = remainingChange % 25;
// Determine number of nickels and determine remaining change
nickels = remainingChange / 5;
remainingChange = remainingChange % 5;
// Determine number of pennies and determine remaining change
pennies = remainingChange / 1;
remainingChange = remainingChange % 1;
// Display result
cout << "The change due is $" << change << ": " << fifties << " $50 bill(s), " << tens << " $10 bill(s), " << ones << " $1 bill(s), " << quarters << " quarter(s), " << nickels << " nickel(s), and " << pennies << " penny(ies).\n\n";
return 0;
}