My assignment was to write a program for an automatic teller machine that dispenses money. User should enter amount (some even multiple of ten) and the machine dispenses that amount using the least amount of bills. The machine stocks $50, $20, and $10 bills. I have to use a single function that will determine the number of each denomination of bills to dispense and the must send all three results back to the calling function using output (reference) parameters. I think they're called pointers in c. But yeah so I have a code I've been working on. It's all over the place but I think I have the general idea. I compile it and get this error message:
/tmp/ccdM4LCy.o:money.c.text+0x1b): undefined reference to `GetInteger'
collect2: error: ld returned 1 exit status
... Now I have no idea what that means. So some help would be nice
Code:
GNU nano 2.2.6 File: money.c
/* Program for automatic teller machine that dispenses money
Written by Kim
October 2013
Language: C (gcc target)
*/
#include <stdio.h>
/*Function prototypes*/
int GetBills (int dollars, int* fifties, int* twenties, int* tens);
void PrintBills(int dollars, int fifties, int twenties, int tens);
int main()
{
int dollars, fifties, twenties, tens;
printf("Enter dollar amount desired:\n");
dollars = GetInteger();
GetBills(dollars, &fifties, &twenties, &tens);
}
int GetBills(int dollars, int *fifties, int *twenties, int *tens)
{
*fifties = dollars / 50;
*twenties = (dollars %= 50) / 20;
*tens = (dollars %= 20) / 10;
return *fifties || *twenties || *tens;
}
void PrintBills(int dollars, int fifties, int twenties, int tens)
{
printf("Dispensing %d dollars...", dollars);
if(fifties)
printf("%d $50 bills\n", fifties);
if(twenties)
printf("%d $20 bills\n", twenties);
if(tens)
printf("%d $10 bills\n", tens);
printf("\n");
return ;
}