# Answer to Question #6831 in C++ for ledua soqonidobui

Question #6831
Write a set of detailed, step-by-step instructions in English to calculate the fewest number of dollar bills needed to pay a bill of amount TOTAL. For example, if TOTAL is \$97, the bills would consist of one \$50 bill, two \$20 bills, one \$5 bill, 2\$and \$1 bills. (For this exercise, assume that only \$100, \$50, \$20, \$10, \$5,2\$and \$1 bills are available.) b. Repeat Exercise 6a, but assume the bill is to be paid only in \$1 bills. To simplify matters, you will all work with a sum of \$283.00 i would like to have a structured chart design and pseudocode alogrithm along with the actual coding on c++
For using fewest number of dollar bills, all bills must be biggest amount.
For example, at first must be calculate maximum number of \$100 dollar bill, then \$50 dollar bill, till \$1 dollar bill.

Algorithm:
1. Calculate maximum number of \$100 bills as integer part of division total amount by bill’s amount (\$100 for this case).
2. Decrease total amount by amount of \$100 bills which calculated in previous step.
3. Repeat first and second steps for other bills in descending order.

Code of program:

#include <iostream>
#include <conio.h>

using namespace std;

int main(int argc, char* argv[])
{
/// Number of bills.
const int billsNumber = 7;

/// Bills amount.
int bills[billsNumber] = {100, 50, 20, 10, 5, 2, 1};

/// Input value which would split for fewest number of dollar bills.
int totalAmount;

/// Total number of bills.
int totalBillsNumber = 0;

do
{
& cout<<"Input the total amount: ";
& cin>>totalAmount;

& int count = 0;

& /// For each bill calculate it's max number.
& while (totalAmount > 0)
& {
& /// Calculate number of bills amount of bills[count] as a integer part of
& /// division amount to bill's amount.
& int billsNumber = totalAmount / bills[count];

& totalBillsNumber += billsNumber;

& /// Display result.
& cout<<"Number of \$"<<bills[count]<<"\tbills is "<<billsNumber<<endl;

& totalAmount -= billsNumber * bills[count];
& count++;
& }

& /// Number of bills is zero for any bills with less amount.
& while(count < billsNumber)
& {
& /// Display result.
& cout<<"Number of \$"<<bills[count]<<"\tbills is 0"<<endl;
& count++;
& }

& cout<<"Total number of bills is "<<totalBillsNumber<<endl;

& totalBillsNumber = 0;

& cout<<"Repeat?(y/n)"<<endl;

while(getch() == 'y');

return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!