so i have been taking my c++ class for about a couple months and really had no problems till we hit functions. The other assignments with functions I eventually got, but this one is eluding me to no end. I think I am heading in the right direction, but just don't understand how to get it quite what I want to do.
Essentially whats asked is that this program takes a dollar value entered and breaks it down into the lowest combination of bills. Its in pass by reference chapter, but I'm just not getting it =( any help is much appreciated.
#include <iostream>
using namespace std;
void change(int &,int &,int &,int &,int &,int &);
int main()
{
float dollar;
int hundreds,fifties,twenties,tens,fives,ones;
cout << "Enter dollar amount :\n";
cin >> dollar;
change(hundreds,fifties,twenties,tens,fives,ones);
cout << "Least change of" << dollar << "is...";
cout << "Hundreds :" << hundreds;
cout << "Fifties :" << fifties;
cout << "Twenties :" << twenties;
cout << "Tens :" << tens;
cout << "Fives :" << fives;
cout << "Ones :" << ones;
}
void change(int &hundreds, int &fifties, int &twenties, int &tens, int &fives, int &ones)
{
int dollar;
int total;
while(total >=0)
hundreds = dollar/100;
total = total - hundreds;
fifties = dollar/50;
total = total - fifties;
twenties = dollar/20;
total = total - twenties;
tens = dollar/10;
total = total - tens;
fives = dollar/5;
total = total - fives;
ones = dollar/1;
total = total - ones;
return;
}