Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that receives as input an amount of change from 1 to 99 cents. T

ID: 3543212 • Letter: W

Question

Write a program that receives as input an amount of change from 1 to 99 cents. The program should then indicate how many quarters, dimes, nickles, and pennies should given as change.


Create a function with the following prototype that assists with this task: void ComputeCoins(int coin Value, in& num, int & amount_left); This function would then take, as input, a coin value(such as 10 for a dime) along with the current amount of change left to give (in num). Upon exit "num" should be set to the number of coins of size "coinValue and "amount_left" should be the remaining in change.





Explanation / Answer

#include<iostream>
using namespace std;
void ComputeCoins(int coin_Value, int& num, int & amount_left)
{
num = amount_left/coin_Value;
amount_left = amount_left-num*coin_Value;
}
int main()
{
int quarters=0;
int dimes=0;
int nickles=0;
int pennies=0;
int amount;
cout << "Enter the value of amount :";
cin >> amount;
cout << endl;
cout <<"Amount " << amount << " is equal to " << endl;
ComputeCoins(25,quarters,amount);
ComputeCoins(10,dimes,amount);
ComputeCoins(5,nickles,amount);
ComputeCoins(1,pennies,amount);
if(quarters)
cout << quarters << " quarters " << endl;
if(dimes)
cout << dimes << " dimes " << endl;
if(nickles)
cout << nickles << " nickles " << endl;
if(pennies)
cout << pennies << " pennies " << endl;
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote