i have this simple program im writing to help my dads business.
thoguh it doesnt seem to be working, this is what i have currently
#include<iostream>
using namespace std;
int change(double money,int onedollar,int fiftycent,int twentycent,int tencent,int fivecent);
int main()
{
int money, onedollar, fiftycent, twentycent, tencent, fivecent;
cout << "Enter amount: ";
cin >> money;
change(money, onedollar, fiftycent, twentycent, tencent, fivecent);
cout << "One Dollar: " << onedollar << endl;
cout << "Fifty Cent: " << fiftycent << endl;
cout << "Twenty Cent: " << twentycent << endl;
cout << "Ten Cent: " << tencent << endl;
cout << "Five Cent: " << fivecent << endl;
return 0;
}
int change(float money, int onedollar, int fiftycent, int twentycent, int tencent, int fivecent)
{
float temp;
temp = money;
temp *= 100;
onedollar = temp/100;
temp = temp%100;
fiftycent = temp/50;
temp = temp%50;
twentycent = temp/20;
temp = temp%20;
tencent = temp/10;
temp = temp%10;
fivecent = temp/5;
return 0;
}
i dont know if ive got the right idea or anything
this is sorta what im trying to write, a C++ function, named change(), that has a floating-point parameter and 5 integer reference parameters named onedollars, fiftycents, twentycents, tencents and fivecents. The function is to consider the floating-point passed value as a dollar amount and convert the value into an equivalent number of dollar coins, fifty, twenty, ten and five cents coins. Using the references, the function should directly alter the respective arguments in the calling function.
For example, calling the function with the following arguments: change(78.85, onedollars, fiftycents, twentycents, tencents, fivecents); will assign the following values to the appropriate variables:
onedollars = 78
fiftycents = 1
twentycents = 1
tencents = 1
fivecents = 1
any help wuld b awsome