CS 204 – Test 2 Study Guide:
Sources for
terms definition:
Programming Terms
General Terms
Software Development:
Problem-Solving Steps:
1. Identify the Problem
2. Understand
the Problem
3. Identifying a List of Possible
Solutions
4. Writing the Algorithm
5. Prototyping the Solution
6. Implementing and Testing the Solution
Algorithm for an Elevator:
Steps:
1. The
first thing our elevator will handle is the pushing of buttons. When a button is pushed, the number of the
requested floor will be immediately placed on a list of floors to visit. These floors will be visited in the order
requested, unless another floor is requested along the way, in which case the
elevator will stop to let people off.
2. Handling
the doors is the next step. Ever noticed
how elevators like to keep their doors closed?
This step will attempt to close the doors, if they are open. Attempts will be made every 5 seconds and
will close the doors unless something gets in the way.
3. If the
doors are closed and the elevator car is on a floor that was requested, the
doors will open. Ever notice that
elevators will take you to a level, then wait a few
seconds to open the doors? This is
related to the way the computer program instructions are sequenced. There are three separate steps for the
elevator: Getting the car to the floor requested, realizing it is there, and
opening the door.
4. If the
doors are closed and the request list is not empty then move the car one level
towards the next floor on the request list.
This is how the elevator moves the car up and down, one floor at a time.
It then figures out what to do at that level in a later step.
5. That’s
it! Go back to step one and repeat all
of these.
Algorithm with Structure:
Steps:
1. If
button is pushed then:
Add level number to request list
Goto step
1
2. If doors
are open then:
Wait 5 seconds
Ring
Attempt to Close
doors
Goto step
1
3. If doors
are closed and elevator car is on a level that has been requested then:
Ring
Open doors
Goto step
1
4. If doors
are closed and request list is not empty then:
Move elevator one level towards next
level on request list
Goto step
1
5. Goto step 1
Additional
Things to Study:
· Pseudocode, study the online instructions
· Binary, Hex, Octal Conversions, study the handouts
· Assignments and Expressions, study online
instructions
· If Statements and logical expressions such as IF (A
< B) then
·
· Terms and concepts from the first 3 chapters of the