• 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. 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.

    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

    • 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."
  • 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

    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
          when yes, then
            check if the account balance is less than \$1000
              when 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
            when yes, then
              tell the teller to charge the minimum balance fee
            otherwise
              tell the teller to not charge the minimum balance fee
        ask the user if there are more accounts to be checked
      Using block diagrams:
  • Write the program

    translate your algorithm into code, minimum_balances.c:

  • Modify the program

      update the program to support this change in user interface:
    • was:
      Are you finished checking all your accounts?
      Enter 'n' to check more accounts; Enter any other character to exit
    • is:
      Do you want to exit?
      Enter 'y' to exit; Enter any other character to continue
  • Assignment

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

    • a file named UHusername_10_1.c
      • example:
      • zhaol_10_1.c

      improve minimum_balances.c to allow the user to cancel the program when the program is asking the teller what type of account:

      In other words, the user can choose saving account ('s'), checking account ('c'), or exit program ('x'), saving the user from answering another question

    • Test Case 1:
      c = checking, s = saving, x = exit
      Please enter the account type:
      [user enters c]
      Please enter the account balance: [user enters 100]
      A minimum balance fee needs to be charged to this account.
      c = checking, s = saving, x = exit
      Please enter the account type:
      [user enters x]
      Exiting program...
      
    • Test Case 2:
      c = checking, s = saving, x = exit
      Please enter the account type:
      [user enters x]
      Exiting program...