September 2018
Intermediate to advanced
328 pages
9h 10m
English
The fourth section contains functions to calculate the grand totals and final balances for raw and cooked transactions, as follows:
void calculateGrandTotals(float *totalRaw, float *totalCooked) { struct Node *node = transactionsHead; while (node != NULL) { *totalRaw += node->rawAmount; *totalCooked += node->cookedAmount; node = node->next; }}float getGrandTotalForType(AmountType type) { float totalRaw = 0; float totalCooked = 0; calculateGrandTotals(&totalRaw, &totalCooked); if (type == RAW) return totalRaw; if (type == COOKED) return totalCooked; return 0;}float getFinalBalanceForType(AmountType type, float initialBalance) { float totalForType = getGrandTotalForType(type); return initialBalance + totalForType; ...Read now
Unlock full access