c++ This program takes one change value (between 1 and 99) and prints out what coins can be used to make that change. Us

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

c++ This program takes one change value (between 1 and 99) and prints out what coins can be used to make that change. Us

Post by answerhappygod »

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:
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 that reads thechange values from a data file one value at a time. For each valueread, it computes and displays what coins can be used to make thatchange.
coins.dat file
86305669884590387527491729
#include <iostream>using namespace std;
// declare all the user defined functions here
int main() {
return 0;}
// define all the user defined functions below
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply