Discover the best answers at Westonci.ca, where experts share their insights and knowledge with you. Join our platform to connect with experts ready to provide accurate answers to your questions in various fields. Connect with a community of professionals ready to provide precise solutions to your questions quickly and accurately.

Create the logic for a program that continuously prompts the user for a number of dollars until the user enters 0. Pass each entered amount to a conversion method that returns a breakdown of the passed amount into the fewest bills. Display the bills in the main program.

The bills are 100-dollar bills, 50-dollar bills, 20-dollar bills, 10-dollar bills, 5-dollar bills, and 1-dollar bills.

if the number of dollars is 37 then the function returns 1 20-dollar bill, 1 10-dollar bill, 1 5-dollar bill, and 2 1-dollars bills.

if the number of dollars is 98 then the function returns 1 50-dollar bill, 2 20-dollar bills, 1 5-dollar bill, and 3 1-dollar bills.

Suppose the number of bills is 186. What will your function return?


Sagot :

Using the knowledge in computational language in C++ it is possible to write a code that Create the logic for a program that continuously prompts the user for a number of dollars until the user enters 0.

Writting the code:

#include<iostream>

using namespace std;

void displayBills(int dollars)

{

int ones,fives,tens,twenties,temp;

twenties = dollars / 20;

temp = dollars % 20;

tens = temp / 10;

temp = temp % 10;

fives = temp / 5;

ones = temp % 5;

cout<< "\nThe dollar amount of ", dollars, " can be represented by the following monetary denominations\n";

cout<<"twenties: "<<twenties<<"\ntens: "<<tens<<"\nfives: "<<fives<<"\nones: "<<ones;

}

int main()

{

int dollars;

cout<<"Please enter the a whole dollar amount (no cents!). Input 0 to terminate: ";

cin>>dollars;

while(dollars!=0)

{

displayBills(dollars);

cout<<"\nPlease enter the a whole dollar amount (no cents!). Input 0 to terminate: ";

cin>>dollars;

}

return 0;

}

See more about C++ at brainly.com/question/18502436

#SPJ1

View image lhmarianateixeira
Visit us again for up-to-date and reliable answers. We're always ready to assist you with your informational needs. Thank you for choosing our platform. We're dedicated to providing the best answers for all your questions. Visit us again. Find reliable answers at Westonci.ca. Visit us again for the latest updates and expert advice.