Hello, so i'm pretty new at c++ and i need to make a program that breaks down a amount of money entered by bills and cents. I have it almost done completely done, but i'm having trouble knowing if i used functions correctly in the program.
#include <iostream>
#include <iomanip>
using namespace std;
void changeMoney( int);
int main()
{
double dineroTotal;
int dollarAmount;
int centsAmount;
cout << "Favor entrar el valor de los billetes\n";
cin >> dollarAmount;
while (dollarAmount < 0)
{
int temp;
cout << "Usted esta entrando una cantidad negativa favor entre la cantida en dolares positiva";
cin >> temp;
dollarAmount = temp;
}
changeMoney(dollarAmount); // Calling function
return 0;
}
void changeMoney(int dineroTotal)
{
int dollarAmount;
int valorBilletes[6] = { 100,50,20,10,5,1 };
int cantidadBilletes[6] = { 0,0,0,0,0,0 };
int valorCentavos[4] = { 25, 10, 5, 1 };
int cantidadCentavos[4] = { 0,0,0,0 };
int Moneda, SobraM;
int sobra, dinero;
double DineroTotal;
cin >> DineroTotal;
int a = DineroTotal * 100;
dinero = a / 100;
Moneda = a % 100;
for (int x = 0; x < 6; x++)
{
cantidadBilletes[x] = dinero / valorBilletes[x];
sobra = dinero % valorBilletes[x];
dinero = sobra;
cout << "Billetes de " << valorBilletes[x] << "=" <<
cantidadBilletes[x] << "\n";
}
for (int i = 0; i < 4; i++)
{
cantidadCentavos[i] = Moneda / valorCentavos[i];
SobraM = Moneda % valorCentavos[i];
Moneda = SobraM;
cout << "Monedas de " << valorCentavos[i] << "=" <<
cantidadCentavos[i] << "\n";
}