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

Using C++ Part 2 - Cash.cpp Write a function called SortCash() that has eight (8

ID: 3856531 • Letter: U

Question

Using C++

Part 2 - Cash.cpp

Write a function called SortCash() that has eight (8) parameters. The first parameter should be a pass by value integer that represents a total dollar amount. The remaining seven parameters should also be integers but passed by reference. These reference parameters will represent standard Canadian currency amounts: hundred dollar bills, fifty dollar bills, twenties, tens, fives, toonies and loonies, respectively in that order.

The function should convert the total dollar amount into the least number of equivalent bills/coins. Using references, the function should directly alter the respective arguments of the calling function. This function should only handle processing. Input and output to the console should not be in this function.

Include the function in a working program which prompts the user for the total dollar amount and shows them the list of equivalent bill/coin quantities. Loop this IPO structure 3 times. Be sure to validate for non-numeric input by including the MyInputValidation.h custom header file. The minimum allowable dollar amount is one (1), the maximum is one thousand (1000).

Cash.cpp: Please ente a total dolla amount 456 umber of Loonies: umber of Toonies: umber of Fives: umber of Tens: unber of Twenties: umber of Fifties: umber of Hundreds: 0 lease enter a total dollar amount 37 unber of Loonies: unber of Toonies: unber of Fives: unber of Tens umber of Twenties: umber of Fifties umber of Hundreds: 0 0 Please ente a total dollar amount: 212 unber of Loonies: mber of Toonies: umber of Fives: umber of Tens: umber of Twenties: umber of Fifties: unber of Hundreds 0 0 0 0 Press any key to continue. . .

Explanation / Answer

#include <iostream>
#include <iomanip>
using namespace std;
float Calc(int dollars, float &loonies, float &toonies, float &hundreds, float &fifties,
float &twenties, float &tens, float &fives)
{
float tot;
loonies = dollars / 100;
float tot1 = dollars % 100;
toonies = dollars / 200;
float tot2 = dollars % 200;
hundreds = dollars / 100;
tot = dollars - (hundreds * 100);
fifties = tot / 50;
tot = tot - (fifties * 50);
twenties = tot / 20;
tot = tot - (twenties * 20);
tens = tot / 10;
tot = tot - (tens * 10);
fives = tot / 5;
tot = tot - (fives * 5);
}

int main()
{
int dollars;
float tot1, tot2;
float loonies, toonies, hundreds, fifties, twenties, tens, fives;
cout<<" Please Enter a Total Dollar Amount:";
cin>>dollars;
Calc(dollars, loonies, toonies, hundreds, fifties, twenties, tens, fives);
cout<<setprecision(0) <<fixed;
cout<<" Number of Loonies: " <<setw(5) <<tot1;
cout<<" Number of Toonies: " <<setw(5) <<tot2;;
cout<<" Number of Hundreds: " <<setw(4) <<hundreds;
cout<<" Number of Fifties :" <<setw(5) <<fifties;
cout<<" Number of Twenties: " <<setw(4) <<twenties;
cout<<" Number of Tens: " <<setw(8) <<tens;
cout<<" Number of Fives: " <<setw(7) <<fives;
cout<<" Press any Key to Continue...";
cin.get();
return 0;
}
  

OUTPUT


Please Enter a Total Dollar Amount: 456
Number of Loonies: 0
Number of Toonies: 0
Number of Hundreds: 4
Number of Fifties : 1
Number of Twenties: 0
Number of Tens: 0
Number of Fives: 0
Press any Key to Continue...

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