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 04:31
Type the correct answer in the box. spell all words correctly. the managing director of a company sends a christmas greeting to all his employees through the company email. which type of network does he use? he uses an
Answers: 1
question
Computers and Technology, 25.06.2019 07:00
How do the portrait and landscape page orientations in the process of printing a worksheet?
Answers: 1
question
Computers and Technology, 25.06.2019 07:30
What does the hard disk drive do? it stores all of the information on a computer. it controls a computer’s operating system. it enables visual interaction with a computer. it contains all of a computer’s internal parts.
Answers: 1
question
Computers and Technology, 25.06.2019 20:30
Drag each tile to the correct box. shawn has been assigned to create a storyboard for an online grocery website. organize the steps he needs to follow to create a storyboard in the correct order.
Answers: 2
You know the right answer?
Write a program that tells what coins to give out for any amount of change from 1

cent...
Questions
question
English, 17.02.2021 23:00
question
Mathematics, 17.02.2021 23:00
question
English, 17.02.2021 23:00
question
Mathematics, 17.02.2021 23:00
question
Mathematics, 17.02.2021 23:00
Questions on the website: 13722361