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

Using C++ ( I have the code, i just need a loop that will make it loop 3 times a

ID: 3857586 • Letter: U

Question

Using C++ ( I have the code, i just need a loop that will make it loop 3 times at the end an restrict the values from 1 to 1000)

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)

*********************************( I have the code, i just need a loop that will make it loop 3 times at the end an restrict the values from 1 to 1000) *************************************

Explanation / Answer

Here is the function for looping it 3 times. Hope it helps...

Cash.cpp

#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

int main()
{
long long no;
string str;
int maximum = 0;
vector<string> coa;
map<string, int> cnt;
cout << "Enter the number" << no <<endl;
cin >> no;

for(int uu = 0; uu <= no; uu++)
{
getline(cin, str);
coa.push_back(str);
}

for(vector<string>::iterator iterate1 = coa.begin(); iterate1 != coa.end(); ++iterate1)
{
if(cnt.find(*iterate1) == cnt.end())
cnt[*iterate1] = 1;
else
cnt[*iterate1] += 1;
}

for(map<string, int>::iterator iterate2 = cnt.begin(); iterate2 != cnt.end(); ++iterate2)
{
if(iterate2->second > maximum)
maximum = iterate2->second;
}

cout << maximum << endl;
return 0;
}

Please rate the answer if it helped.....Thankyou

Hope it helps....

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