This repository has been archived by the owner on Apr 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
refactored_net_balance.c
56 lines (48 loc) · 2.53 KB
/
refactored_net_balance.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* File: refactored_net_balance.c
// By: The Awesome Students of EE160
// Date: Today :)
*/
#include <stdio.h>
#include "macros.h"
#include "functions.h"
#include "functions.c"
// This program allows a teller to enter in account details and the program will calculate account information for the teller
int main() {
float account_balance;
char account_type;
char exit_program_flag = CONTINUE_PROGRAM;
int total_number_of_accounts = 0;
float total_amount_in_accounts = 0;
int minimum_balance_fee = 35;
int total_minimum_balance_fees = 0;
int total_accounts_with_minimum_balance_fees = 0;
int minimum_balance_fee_charged_flag = 0;
while (exit_program_flag == CONTINUE_PROGRAM) {
account_balance = get_account_balance();
account_type = get_account_type();
if (account_type == 's') {
minimum_balance_fee_charged_flag = is_account_below_minimum_balance(account_balance, SAVINGS_ACCOUNT_MINIMUM_BALANCE);
} else {
minimum_balance_fee_charged_flag = is_account_below_minimum_balance(account_balance, CHECKING_ACCOUNT_MINIMUM_BALANCE);
}
// Display account summary information
if (minimum_balance_fee_charged_flag) {
total_accounts_with_minimum_balance_fees++;
total_minimum_balance_fees += minimum_balance_fee;
printf ("Minimum Balance Fee to Account Balance Percentage: %.1f%%\n", minimum_balance_fee / account_balance * PERCENT_CONVERSION_FACTOR);
printf ("The new account balance is $%.2f\n", net_balance(account_balance, minimum_balance_fee));
} else {
printf ("Minimum Balance Fee to Account Balance Percentage: %.1f%%\n", NO_MINIMUM_BALANCE / account_balance);
printf ("The new account balance is $%.2f\n", net_balance(account_balance, NO_MINIMUM_BALANCE));
}
update_account_summary_information(&total_number_of_accounts, &total_amount_in_accounts, account_balance);
exit_program_flag = ask_to_exit();
}
// Display accounts summary information
printf ("==== Accounts Summary ====\n");
printf ("The total number of accounts: %d\n", total_number_of_accounts);
printf ("The total amount in all accounts: $%.2f\n", total_amount_in_accounts);
printf ("The percentage of the total minimum balance fees with respect to the total account balances: %.1f%%\n", total_minimum_balance_fees / total_amount_in_accounts * PERCENT_CONVERSION_FACTOR);
printf ("The percentage of accounts that were charged a minimum balance fee: %.1f%%\n", PERCENT_CONVERSION_FACTOR * total_accounts_with_minimum_balance_fees / total_number_of_accounts);
return 0;
}