• Problem Statement

    The Bank of EE160 manager wants to start tracking the teller line movements to gain insight into when the busiest and least busiest times are for the bank. This information can eventually help the manager schedule the right number of tellers to handle the volume of customers. As a first step, the program needs to model the behavior of the teller lines. Write a program that allows the manager enter in the customer id to add the customer to the line, 0 to remove the first customer from the line, and -1 to quit the program. The program also prints out the status of the line after each command entered by the manager.

    What is the problem asking for?

    A program that keeps track of a teller line based on input from the manager. The program prints out the status of the line after each input from the manager.

    • input:
      • manager input (integer)
    • output:
      • the status of the line
  • Visualize the Behavior of the Line

    Behavior of the Line
    Manager InputStatus of the Line
    11
    21, 2
    31, 2, 3
    02, 3
    42, 3, 4
    03, 4
    04
    -1program ends
  • 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 input is a -1
    • it needs to check if the input is a 0
      What are some tasks the program need to do:
    • it needs to display the status of the line
    • it needs to add a customer to the line
    • it needs to remove a customer from the line

    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 manager input
        check if input is 0
          when yes, then
            check if somebody is in line (first_position_in_line != last_position_in_line)
              remove first customer in line (remove first integer of array at first_position_in_line)
              increment first_position_in_line
          otherwise
            add new customer to end of line (add input to array at last_position_in_line)
            increment last_position_in_line
      
        set display_counter to 0
        while display_counter is less than MAX_NUMBER_OF_CUSTOMERS  
          print array[display_counter]
          increment display_counter
      while input does not equal -1
      Using block diagrams:
  • Write the program

    translate your algorithm into code, teller_line.c:

      Things to note:
    • needed two pointers to the same array
    • could have used two counters with array indexing instead of using pointers
  • How do you solve the max number of customer problem?

    Queue Implementation

    • Start

    • More Customers

    • Less Customers

    • Maximum Number of Customers Exceeded

    Cicular Queue Implementation

    • Start

    • More Customers

    • Less Customers

    • Even More Customers

  • Assignment

    No graded assignments
  • Optional Assignments

    Optional assignments are not graded and does not need to be turned in. It is intended to give you more practice (if you want it) using the programming concepts discussed in lecture. Some optional assignments are intended to introduce related concepts (if you care about it) not discussed in this course to broaden your knowledge about programming in general.

    If the optional assignment is modifying a required assignment, be sure to leave your previous assignment work untouched by copying them to a new folder for the optional assignment and modify only the files in the new folder

    Implement Circular Queue for Teller Line: