Words of Wisdom:

"Here I am,take me as I am or suffer as you are and live with out my love." - Linwy

Computer Science

  • Date Submitted: 05/14/2012 01:25 AM
  • Flesch-Kincaid Score: 73.7 
  • Words: 4903
  • Essay Grade: no grades
  • Report this Essay
Chapter VIIa

Decision Making in NXT

Chapter VIIa Topics

7a.1 Introduction
7a.2 Switch Block Settings
7a.3 One-Way Selection
7a.4 Two-Way Selection
7a.5 Nested Control Structures
7a.6 Multi-Way Selection
7a.7 Compound Conditions
7a.8 Ranges
7a.9 Compound Compound Conditions











7a.1   Introduction


In First Exposure, Unit 05, you learned about special program structures that can repeat a set of instructions.   Lego NXT uses special   blocks and Java uses for and while keywords for repetition.   Repetition is also called looping or the more formal term iteration.   In this chapter you will learn that there are more ways to control program execution besides repetition.

Program-execution-flow is controlled by three general types of control structures.   They are simple sequence, repetition, and selection.   Lego NXT provides program blocks for control structures and Java provides syntax, and special keywords for each of these three control structures.   Before we look at the actual NXT and Java source codes required to implement program control, let us first take a look at a set of diagrams that explain each control structure.


Simple Sequence

[pic]



Simple sequence holds no surprises.   A series of program statements are executed in the exact sequence, in which they are written.   Altering the program execution logic requires altering the sequence of the program statements.   In Lego NXT this means that the program blocks are placed on the sequence beam from left-to-right in the sequence of instructions.   In Java this means that program statements are placed in the program from top-to-bottom in the sequence of required program execution.

Repetition

Another common application occurs when repetition is required.   A grade book program needs to average grades for every student in a class of twenty-five students.   A payroll program needs to process paychecks for many employees.   Practically everything you can...

Comments

Express your owns thoughts and ideas on this essay by writing a grade and/or critique.

  1. No comments