We need an application to prompt the user for a dollar amount (ie 48.87) and the
ID: 3562260 • Letter: W
Question
We need an application to prompt the user for a dollar amount (ie 48.87) and then determine the fewest number of each bill and coin needed to represent that amount, starting with the highest amount(assume that a ten dollar bill is the maximum size bill that you can have). For example, if the value entered is 47.63, then the program should print the equivalent amount as:
4 ten dollar bills
1 five dollar bills
2 one dollar bills
2 quarters
1 dimes
0 nickels
3 pennies
Be sure and design and document your algorithm first before coding.
Put comments your program
Trace through your code before running it.
Test thoroughly with valid data
Explanation / Answer
#include #define LEN 9 // array length int main(){ int coins[LEN]={0,0,0,0,0,0,0,0,0}; // coin count int cointypes[LEN]={1000,500,100,50,20,10,5,2,1}; // declare your coins and note here {ASC order} int sum =0; //temp variable for sum int inc=0; // for loop int amount=0; // for total amount printf("Enter Amount :"); scanf("%d",&amount); while(sumRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.