Please make sure the output be the same and allread from a data file one value at a time. C++ This program takes one ch

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Please make sure the output be the same and allread from a data file one value at a time. C++ This program takes one ch

Post by answerhappygod »

Please make sure the output be the same and allread from adata file one value at a time.
C++
This program takes one change value (between 1 and 99) andprints out what coins can be used to make that change. Use coindenominations of 25 cents (quarters), 10 cents (dimes), and 1 cent(pennies). Do not use nickels and half-dollar coins.
Your program should implement the following function (amongothers):
void ComputeCoin(int cointValue, int& number, int&amountLeft);// Precondition: 0 < coinValue <100; 0 <= amountLeft < 100.// Postcondition: number has been set equal to the maximumnumber// of coins ofdenomination coinValue cents that can be obtained// from amountLeftcents. amountLeft has been decreased by the// value of thecoins, that is, decreased by (number * coinValue).
For example, if the value of the variable amountLeft is 86,after the following call:
the value of number will be 3 and the value of amountLeft willbe 11, because if you take 3 quarters from 86 cents, that leaves 11cents.
After a second call:
ComputeCoins(10, number, amountLeft);
the value of number will be 1 and the value of amountLeft willbe 1, because if you take 1 dime from 11 cents, that leaves 1cent.
Therefore, for this example, the coins can be used to makechange for 86 is 3 quarters and 1 dime and 1 cent.
Your main function should consist of a while loop thatreads the change values from a data file one value at a time. Foreach value read, it computes and displays what coins can be used tomake that change.
Here is an example data file: coins.datfile
86305669884590387527491729
the output from the program should be:
86 cents can be changed using:
3 quarter(s)
1 dime(s)
1 cent(s)
30 cents can be changed using:
1 quarter(s)
0dime(s)
5 cent(s)
56 cents can be changed using:
2 quarter(s)
0 dime(s)
6 cent(s)
69 cents can be changed using:
2 quarter(s)
1 dime(s)
9 cent(s)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply