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

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

    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:
    • 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
      Using block diagrams:
  • Write the program

    translate the algorithm into code, minimum_balance.c:

  • Update the program

    update the program to:

    • ask the user if s/he wants to print out the minimum balance threshold for this account
    • ask the user only if a minimum balance fee needs to be charged
    • print out the minimum balance threshold for the account only if the user wants it
  • Assignment

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

    • a file named UHusername_08_1.c

      example:

      • zhaol_08_1.c
    • rename minimum_balance.c (e.g. zhaol_08_1.c) and modify it to handle the scenario when the account type is not a saving account and not a checking account:
    • test case 1:
      Please enter the account balance:
      [user enters 100]
      c = checking, s = saving
      Please enter the account type:
      [user enters c]
      A minimum balance fee needs to be charged to this account. 
      
    • test case 2:
      Please enter the account balance:
      [user enters 600]
      c = checking, s = saving
      Please enter the account type:
      [user enters c]
      A minimum balance fee does not need to be charged to this account.
      
    • test case 3:
      Please enter the account balance:
      [user enters 600]
      c = checking, s = saving
      Please enter the account type:
      [user enters s]
      A minimum balance fee needs to be charged to this account. 
      
    • test case 4:
      Please enter the account balance:
      [user enters 1000]
      c = checking, s = saving
      Please enter the account type:
      [user enters s]
      A minimum balance fee does not need to be charged to this account.
      
    • test case 5:
      Please enter the account balance:
      [user enters 1000]
      c = checking, s = saving
      Please enter the account type:
      [user enters m]
      The account type entered is not valid.
      

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

    • a file named UHusername_08_2.c

      example:

      • zhaol_08_2.c
    • Write a program that implements the following algorithm:
    • get user's age
      if user is younger than 30 (not including 30)
        tell user they have a bright future ahead of them
      otherwise
        tell user they have years of wisdom to pay forward
        
      ask if user is a programmer
      if user is a programmer
        tell user "if(crazy){change_world()}"
      otherwise
        tell user The people who are crazy enough to think they can change the world, are the ones who do. - Apple
            
      get user's GPA
      if user's GPA is greater than or equal to 0
        if the user's GPA is less than or equal to 4.0
          tell user that there is too much emphasis on this number
        otherwise
          tell user that their GPA is out of this world
      otherwise
        tell user that their GPA is unbelievable
      
    • Test Case 1:
      What is your age:
      [user enters 18]
      You have a bright future ahead of you.
      Are you a programmer? (y,n):
      [user enters n]
      The people who are crazy enough to think they can change the world, are the ones who do. - Apple
      What is your GPA?:
      [user enters 3.0]
      There's too much emphasis on this number.
      
    • Test Case 2:
      What is your age:
      [user enters 30]
      You have years of wisdom that can be paid forward.
      Are you a programmer? (y,n):
      [user enters y]
      if(crazy){change_world()}
      What is your GPA?:
      [user enters 4.1]
      Your GPA is out of this world.
      
    • Test Case 3:
      What is your age:
      [user enters 1]
      You have a bright future ahead of you.
      Are you a programmer? (y,n):
      [user enters n]
      The people who are crazy enough to think they can change the world, are the ones who do. - Apple
      What is your GPA?:
      [user enters -1.0]
      Your GPA is unbelievable.