Question

Write a program that asks the user to enter a U.S. dollar amount and then shows...

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.

Homework Answers

Answer #1
#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;
}
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a progran1 that asks the user to enter a U.S. dollar amount and tben shows...
Write a progran1 that asks the user to enter a U.S. dollar amount and tben shows how to pay that amount using the smallest number of $20, $IO. $5, and $1 biJ ls?
in .java Write a program that asks the user to enter 3 grades and computes the...
in .java Write a program that asks the user to enter 3 grades and computes the minimum and the maximum of those 3 grades and prints it. Hint: Use the Math.min() and Math.max() methods. This program will compute the smallest and highest of 3 grades entered by the user. Enter 3 grades separated by a space: 100 85.3 90.5 Smallest: 85.3 Highest: 100.0 Bye
Write a C++ program that asks the user to enter in three numbers and displays the...
Write a C++ program that asks the user to enter in three numbers and displays the numbers in ascending order. If the three numbers are all the same the program should tell the user that all the numbers are equal and exits the program. Be sure to think about all the possible cases of three numbers. Be sure to test all possible paths. Sample Runs: NOTE: not all possible runs are shown below. Sample Run 1 Welcome to the order...
write a C++ program that asks the user to enter 4 integer numbers then use if...
write a C++ program that asks the user to enter 4 integer numbers then use if ….. elseif ….. elseif ….. else to find the smallest number then display it.
C++ while loop Exercise Write a program that continues to ask the user to enter any...
C++ while loop Exercise Write a program that continues to ask the user to enter any set of numbers, until the user enters the number -1. Then display the total sum of numbers entered and their average. (note that you need to define a counter that counts how many numbers so the average = (sum/n) where n is your counter total. #include <iostream> using namespace std; int main() { int number, n=0, sum=0; cout << "Enter a number to start...
Write a mips assembly language program that asks the user to enter and integer number and...
Write a mips assembly language program that asks the user to enter and integer number and read it. Then ask him to enter a bit position (between 0 and 31) and display the value of that bit.
Write a program that asks the user to enter an odd number and prints out a...
Write a program that asks the user to enter an odd number and prints out a triangle pattern. For example, if the user enters 5, the output is note: There is one space between the numbers in each line 1 3 5 1 3 1 If the user enters 9 the output is: 1 3 5 7 9 1 3 5 7 1 3 5 1 3 1 program language: C++
in c++ Write a C++ program that asks the user to enter an integer number and...
in c++ Write a C++ program that asks the user to enter an integer number and prints it back "vertically" to the screen. Use recursion in your solution. As an example of how the program will work: Please enter an integer: 12345 The integer you entered will print vertically as: 1 2 3 4 5
Write a C program that requests a US dollar amount from the user that will represent...
Write a C program that requests a US dollar amount from the user that will represent a restaurant bill. The program will then calculate 3 tip amounts for this bill: 10%, 15%, and 20%. Use defined constants for the tip percentages. You may use your percentages (for example) as either 10 or 0.10. If you use 10, you will need to divide this by 100 in your calculations. A sample run of this program might look like this (user input...
Write a program that asks the user to enter the number of days and then converts...
Write a program that asks the user to enter the number of days and then converts that value to weeks and days. For example, it would convert 18 days to 2 weeks, 4 days. Display results in the following format: 18 days are 2 weeks, 4 days. Use a while loop to allow the user to repeatedly enter day values; terminate the loop when the user enters a nonpositive value, such as 0 or -20.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT