Write a program that asks the user to enter a U.S. dollar amount and then shows how to pay that amount using the smallest number of $100, $20, $10, and $5 bills. Following are a few test cases for your program: Enter the amount for withdrawal: 125 Please collect your bills as follows: $100: 1 $20: 1 $5: 1 Enter the amount for withdrawal: 94 The amount cannot be withdrawn. Note: Be sure to use integer values throughout, not floating point numbers. Please also note the output format. The program must use simple commands such as cout and cin to ask the dollar amount etc because it is what we covered in class.
#include <iostream> using namespace std; int main() { int n; cout << "Enter the amount for withdrawal"; cin >> n; cout << "Please collect your bills as follows: " << endl; cout << "$100: " << n / 100 << endl; n %= 100; cout << "$20: " << n / 20 << endl; n %= 20; cout << "$10: " << n / 10 << endl; n %= 10; cout << "$5: " << n / 5 << endl; n %= 5; cout << "$1: " << n << endl; return 0; }
Get Answers For Free
Most questions answered within 1 hours.