• Problem Statement

    Write a program for the Bank of EE160. The teller will type in the account type and account balance. The program will let the teller know if a minimum balance fee needs to be charged and also the balance after adjusting for the minimum balance fee. The Bank of EE160 has saving accounts and checking accounts. For saving accounts, the minimum balance is \$1,000. For checking accounts, the minimum balance is \$500. The program will allow the teller to continue entering in account balances and types until the teller is done entering all of the accounts.


    The program will also print out a summary of all the accounts. This summary will contain the total number of accounts, the total amount in all accounts, the percentage of minimum balance fees relative to the total amount in all accounts, and the percentage of accounts that were charged a minimum balance fee. Also, after the teller has finished entering in each account's information, the program will calculate the percentage the minimum balance fee is relative to the account balance.

    Assume the minimum balance fee is $35

    What is the problem asking for?

    A program that takes in the account type and account balance. The program returns whether or not a minimum balance fee should be charged to the account

    The program prints a summary of all the accounts detailing the total number of accounts and total amount in all accounts

    • input:
      • account balance (decimal number)
      • account type (character)
      • exit program (character)
    • output:
      • message telling the teller if the minimum balance fee should be charged or not ("A minimum balance fee needs to be charged to this account." or "A minimum balance fee does not need to be charged to this account."
      • accounts summary with the following information:
        • total number of accounts
        • total amount in all accounts
        • percentage of total minimum balance fees charged compared to the total balance of all the accounts
        • percentage of accounts that were charged a minimum balance fee
      • each account will also have a summary with the following information:
        • percentage of the minimum balance fee charged compared to the account balance of each of the accounts
  • Algorithm Design

    How can a computer solve this in a step-by-step manner?

      What are some questions the program needs to ask:
    • it needs to check if the account is a saving account
    • it needs to check if the account is a checking account
    • it needs to check if the account balance is less than $1,000 for saving account
    • it needs to check if the account balance is less than $500 for checking account
    • it needs to check if the teller wants to exit the program
      What are some tasks the program need to do:
    • it needs to display a message to tell the teller to charge a minimum balance
    • it needs to display a message to tell the teller to not charge a minimum balance
    • it needs to continue reading in account balances and account types until the user wants to exit the program
    • it needs to count the number of accounts
    • it needs to total the amount of all the accounts
    • it needs to calculate the percentage of minimum balance fees charged compared to the total amount of all the accounts
    • it needs to calculate the percentage of minimum balance fee charged compared to the the balance on the account for each account
    • it needs to calculate the adjusted balance after the minimum balance fee is accounted for

    How can we arrange the questions and tasks to develop an algoirthm (step-by-step procedure) that will meet our requirements?:

      Some questions to ask:
    • How can we simplify the problem?
    • What order should the questions be asked?
    • What order should the program tasks be done?

    What is the algorithm?

      Using words:
    • while there are more accounts to be checked
        check if the account is a saving account
          if yes, then
            check if the account balance is less than \$1000
              if yes, then
                tell the teller to charge the minimum balance fee
              otherwise
                tell the teller to not charge the minimum balance fee
        otherwise (assume) the account is a checking account
          check if the account balance is less than \$500
            if yes, then
              tell the teller to charge the minimum balance fee
            otherwise
              tell the teller to not charge the minimum balance fee
        display account summary for individual account
        update accounts summary information
        ask the user if there are more accounts to be checked
      display accounts summary information
      Using block diagrams:
  • Write the program

    translate your algorithm into code, net_balance.c:

      Things to note:
    • you can:
      • declare the function
        float net_balance(float account_balance, float minimum_balance);
      • use the function
        net_balance(some_float, another_float);
      • then define the function
        float net_balance(float account_balance, float minimum_balance_fee) {
          return(account_balance - minimum_balance_fee)
        }
    • you can also:
      • declare & define the function
        float net_balance(float account_balance, float minimum_balance_fee) {
          return(account_balance - minimum_balance_fee)
        }
      • then use the function
        net_balance(some_float, another_float);
  • Use Functions in Accounts Summary Information

      replace the calculation of the following with functions:
    • "percentage of the total minimum balance fees with respect to the total account balances"
    • "percentage of accounts that were charged a minimum balance fee"
  • Assignment

    Homework Problem 16.1, at the end of this problem you should submit to Laulima:

    • a file named UHusername_16_1.c
      • example:
      • zhaol_16_1.c
    • modify net_balance.c (without changing the program functionality) so the block of code to display account information is performed using a function named display_account_summary_info:

    • Note: what you've done is called refactoring