• Problem Statement

    Write a program for the Bank of EE160. The teller will type in the account holder, account type, and account balance. The program will let the teller know if a minimum balance fee needs to be charged, the balance after adjusting for the minimum balance fee, and if the teller has entered in an invalid account type. The program will also let the teller know that the account holder is on the bank's stop list and needs to be handled differently. 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 to a file 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 display the account holder information and calculate the percentage the minimum balance fee is relative to the account balance.

    After the summary of all the accounts, the program will print out to another file a list of all the account balances entered by the teller.

    Assume the minimum balance fee is $35

    Currently, the only person on the stop list is Obama

    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 holder (string)
      • 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."
      • message telling the teller if s/he has entered in an invalid account type
      • each account will also have a summary with the following information:
        • account holder information
        • percentage of the minimum balance fee charged compared to the account balance of each of the accounts
      • a file with the accounts summary containing 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
      • a file with a list of account balances entered by the teller
      • message telling the teller to handle the account differently if the account holder is on the stop list
  • 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
    • it needs to list the account balances in a file
    • it needs to display the account holder information
    • it needs to output a file with the accounts summary information:
      • number of accounts
      • amount of all the accounts
      • percentage of minimum balance fees charged compared to the total amount of all the accounts
    • it needs to make sure the account type entered is valid
    • it needs to tell the teller to handle the account differently if the account holder is on the stop list

    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:
    • do
        get account holder information
        check if the account holder is on the stop list
          when yes, then tell the teller to handle the account differently and exit loop
        check if the account is a saving account and less than \$1000
          when yes, then tell the teller to charge the minimum balance fee
        when no, check if the account is a checking account and less than \$1000
          when yes, then tell the teller to charge the minimum balance fee
        otherwise
          check if the account is not a valid account type
            when yes, tell the teller that the account type is invalid
            otherwise, tell the teller to not charge the minimum balance fee
      
        check if the account type was valid
          when yes, then
            display account holder information
            display account summary for individual account
            update accounts summary information
            update list of account balances
        ask the user if there are more accounts to be checked
      while there are more accounts to be checked
      
      output accounts summary information to a file
      output list of account balances to a file
      Using block diagrams:
  • Write the program

    translate your algorithm into code, stop_list.c:

    translate your algorithm into code, functions.h:

    translate your algorithm into code, functions.c:

    translate your algorithm into code, macros.h:

      Things to note:
    • the code to output to file is still executed
    • to exit the program completely replace break with return
  • Update the program so the teller can continue entering in the next account information

  • Assignment

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

    • a file named UHusername_30_1.c
    • a file named UHusername_30_1_macros.h
    • a file named UHusername_30_1_functions.c
    • a file named UHusername_30_1_functions.h
      • example:
      • zhaol_30_1.c
      • zhaol_30_1_macros.h
      • zhaol_30_1_functions.c
      • zhaol_30_1_functions.h
    • Update stop_list.c and functions.c so the program uses a goto statement to ask the teller to reenter a positive number if the teller enters in a negative number for the account balance (this behaviour continues until the teller enters in a zero or positive number, i.e. use goto to mimic a loop)

    • Test Case 1:
      Please enter the account holder:
      [user enters bush]
      Please enter the account balance:
      [user enters -100]
      Please enter a positive account balance
      Please enter the account balance:
      [user enters -120]
      Please enter a positive account balance
      Please enter the account balance:
      [user enters 100]
      c = checking, s = saving
      Please enter the account type:
      [user enters c]
      === Account Information for bush's Account ===
      Minimum Balance Fee to Account Balance Percentage: 35.0%
      The new account balance is $65.00
      
      Are you finished checking all your accounts?:
      Enter 'n' to check more accounts; Enter any other character to exit
      [user enters y]
      Successfully opened file
      Successfully opened file