Quote:
#include <stdio.h>
#include <stdlib.h>
int main(void);
void makechange(float cost, float payment, float *change,
int *twentiesInTill, int *tensInTill, int *fivesInTill
int *dollarsInTill, int *quartersInTill, int *dimesInTill
int *nickelsInTill, int *penniesInTill, int *twentiesInChange,
int *tensInChange, int *fivesInChange, int *dollarsInChange,
int *nickelsInChange, int *penniesInChange);
FILE *transactions;
transactions = fopen ("transactions.dat", "r");
if (transactions == NULL)
{
printf ("File, transactions, could not be opened\n");
}
FILE *change;
change = fopen ("change.dat, "w");
if (change == NULL)
{
printf ("File, change, could not be opened\n");
}
fscanf (transactions, "%f", &cost);
printf ("The cost is %f\n", cost);
fscanf (transactions, "%f", &payment);
printf ("The customer's payment was %f\n", payment);
*change=cost-payment;
fscanf (transactions, "%f-%f=%f"\n, cost, payment, *change);
printf ("The change due is %f\n", *change);
while (*change > 20) {
*change -= 20;
*twentiesInTill++;
}
while (*change > 10) {
*change -= 10;
*tensInTill++;
}
while (*change > 5) {
*change -= 5;
*fivesInTill++;
}
while (*change > 1) {
*change -= 5;
*dollarsInTill++;
}
while (*change > 0.25) {
*change -= 0.25;
*quartersInTill++;
}
while (*change > 0.10) {
*change -= 0.10;
*dimesInTill++;
}
while (*change > 0.5) {
*change -= 0.5;
*nickelsInTill++;
}
while (*change >0.01) {
*change -= 0.01;
*penniesInTill++;
}