Making a program to calculate change and I cant figure out where ive gone wrong
Program is ment to accept a value from 5-95 and as a multiple of 5 and output the number of coins needed to make up the ammount. valid coins are 50, 20, 10 and 5.
#include<stdio.h>
#include<ctype.h>
void GetCents(int &change)
{
printf("This program will calculate change. Please enter your change betweenn 95-5 and as a multiple of 5.\n");
scanf("%d%*c", &change);
return;
}
int CalcChange(int &coin50, int &coin20, int &coin10, int &coin5)
{
int change;
while(change% 5==0 && change >=5 && change <= 95)
{
if (change >= 50)
{
coin50++;
change = change - 50;
}
else
if (change >= 20)
{
coin20++;
change = change - 20;
}
else
if (change >= 10)
{
coin10++;
change = change - 10;
}
else
if (change >= 5)
{
coin5++;
change = change - 5;
}
else
printf("Please enter an integer in the range of 5-95 and a multiple of 5.\n");
}
return(change);
}
void PrintResults()
{
int coin50, coin20, coin10, coin5;
As I said this function has no sense. Instead of processing of the local variable which always equal to 0 you should pass to the function the value you entered.