I have to create a function that will do all the processing (the billsHundred to coinLoonie calculation), but input and output to console will still be done in int main. How should I go about this. I am really having an issue with producing multiple outputs from the function int cash() so i left that blank in order to see what you guys would suggest.
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int cash();
int main()
{
int dollarAmount;
for (int i = 1; i <= 3; i++)
{
cout << "Enter the total dollar amount: $";
cin >> dollarAmount;
while (cin.fail())
{
cout << "\nThat entry is not valid. Please try again: ";
cin.clear();
cin.ignore(1000, '\n');
cin.clear();
cin >> dollarAmount;
}
int billsHundred = dollarAmount / 100;
int billsFifty = (dollarAmount - (100 * billsHundred)) / 50;
int billsTwenty = (dollarAmount - (100 * billsHundred) - (50 * billsFifty)) / 20;
int billsTen = (dollarAmount - (100 * billsHundred) - (50 * billsFifty) - (20 * billsTwenty)) / 10;
int billsFive = (dollarAmount - (100 * billsHundred) - (50 * billsFifty) - (20 * billsTwenty) - (10 * billsTen)) / 5;
int coinToonie = (dollarAmount - (100 * billsHundred) - (50 * billsFifty) - (20 * billsTwenty) - (10 * billsTen) - (5 * billsFive)) / 2;
int coinLoonie = (dollarAmount - (100 * billsHundred) - (50 * billsFifty) - (20 * billsTwenty) - (10 * billsTen) - (5 * billsFive) - (2 * coinToonie)) / 1;
cout << "\nNumber of 100$ bills = " << billsHundred;
cout << "\nNumber of 50$ bills = " << billsFifty;
cout << "\nNumber of 20$ bills = " << billsTwenty;
cout << "\nNumber of 10$ bills = " << billsTen;
cout << "\nNumber of 5$ bills = " << billsFive;
cout << "\nNumber of Toonies = " << coinToonie;
cout << "\nNumber of Loonies = " << coinLoonie << endl << endl;
}
cout << endl;
return 0;
}
int cash()
{
}