subject

Write a program that tells what coins to give out for any amount of change from 1

cent to 99 cents. for example, if the amount is 86 cents, the output would be

something like the following:

86 cents can be given as:

3 quarter(s), 1 dime(s), and 1 penny (pennies)

use coin denominations of 25 cents (quarters), 10 cents (dimes), and 1 cent

(pennies). do not use nickel and half-dollar coins. your program will use the

following function (possibly among others):

void computecoin( int coinvalue, int& number, int& amountleft );

// precondition: 0
// postcondition: number has been set equal to the maximum

// number of coings of denomination coinvalue cents that

// can be obtained from amountleft cents. amountleft has

// been decreased by the value of the coins, that is,

// decreased by number*coinvalue.

for example, suppose the value of the variable amountleftis 86. then, after the

following call, the value of numberwill be 3 and the value of amountleftwill be 11

(because if you take three quarters from 86 cents, that leaves 11 cents):

computecoins(25, number, amountleft);

testing your program:

be sure to test your program with various values to ensure it provides the correct

output before submitting to get full credit. for extra credit, have your program only

accept proper input values (1 to 99). if the user attempts to enter an invalid

number, your program should output an error message and repeat the input

process until it receives an appropriate value. (hint: use a while or do-while loop.)

could you edit and improvise on this code to work :

#include "stdafx. h"
#include
#include
using namespace std;

void computecoin(int coinvalue, int& number, int& amountleft)

{
number = amountleft/ coinvalue;
amountleft = amountleft - (coinvalue*number);
}

int amount = 0;
int number = 0;
int quarters = 0;
int dimes = 0;
int pennies = 0;
int change = 0;

int main()
{
cout < < " enter the amount desired: " ;
cin> > amount;

do
{
if( amount < 1 || amount > 99)
cout < < " error, enter value between 1 and 99 cents.\n";
}
while( amount > 1 || amount < 99 );
{
amount = change;
amount++;

if (amount < 100 & & amount > = 25)
{
change = amount/25;
quarters++;
}
else if (amount < 25 & & amount > = 10)
{
change = amount/10;
dimes++;
}
else if (amount < 10 & & amount > =0)
{
change = amount/1;
pennies++;
}

computecoin (25, quarters, amount);
cout < < amount < < " " < < number < computecoin (10, dimes, amount);
cout < < amount < < " " < < number <
computecoin (01, pennies, amount);
cout < < amount < < " " < < number < cout< < " the change desired is: " < < change;

}

return (0);

}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 01:10
Are special combinations of keys that tell a computer to perform a command. keypads multi-keys combinations shortcuts
Answers: 1
question
Computers and Technology, 23.06.2019 17:30
Per the municipal solid waste report, what are the most common sources of waste (trash
Answers: 3
question
Computers and Technology, 24.06.2019 08:30
Why might you choose to create a functional resume
Answers: 1
question
Computers and Technology, 24.06.2019 22:10
How many different ways are there to order the eight jobs in the queue so that job usu comes somewhere before cdp in the queue (although not necessarily immediately before) and cdp comes somewhere before bbd (again, not necessarily immediately before)?
Answers: 1
You know the right answer?
Write a program that tells what coins to give out for any amount of change from 1

cent...
Questions
Questions on the website: 13722367