Introduction to Programming with RAPTOR

Slides:



Advertisements
Similar presentations
RAPTOR Syntax and Semantics By Lt Col Schorsch
Advertisements

Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Lecture 2 Introduction to C Programming
Introduction to C Programming
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C Programming
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
Introduction to C Programming
VB Code Statements 3 types of VB statement The Remark statement, known as comments, are used for project documentation only Begin with an apostrophe Not.
Concepts of Database Management Sixth Edition
Raptor Mr. Lau Ka Lun Lai King Catholic Secondary School.
Introduction to MATLAB ENGR 1187 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
Visual Basic Chapter 1 Mr. Wangler.
Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission.
Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs.
JavaScript – Part II Data Types and Operations George Mason University June 3, 2010.
Programming.
INTRODUCTION TO ALGORITHMS PROGRAMMING. Objectives Give a definition of the term algorithm Describe the various parts of the pseudocode algorithm or algorithm.
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
Computers and Scientific Thinking David Reed, Creighton University JavaScript and User Interaction 1.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
1 JavaScript in Context. Server-Side Programming.
Input, Output, and Processing
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Concepts of Database Management Seventh Edition
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
 Pearson Education, Inc. All rights reserved Introduction to Java Applications.
An Object-Oriented Approach to Programming Logic and Design Chapter 1 An Overview of Computers and Logic.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
Introduction to Visual Basic Programming. Introduction Simple Program: Printing a Line of Text Another Simple Program: Adding Integers Memory Concepts.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Three Memory Locations and Calculations.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 – Introduction to C# Programming Outline 3.1 Introduction 3.2 Simple Program: Printing a Line.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Controlling Program Flow with Decision Structures.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Making Interactive Programs with Visual Basic .NET
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Visual Basic.NET Windows Programming
CST 1101 Problem Solving Using Computers
Topics Designing a Program Input, Processing, and Output
Chapter 6 JavaScript: Introduction to Scripting
Chapter 2: Input, Processing, and Output
Chapter 2 - Introduction to C Programming
Variables, Expressions, and IO
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Chapter 2 - Introduction to C Programming
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 2 Applications and Data.
Variables and Arithmetic Operations
Introduction to C++ Programming
T. Jumana Abu Shmais – AOU - Riyadh
Chapter 3 – Introduction to C# Programming
Chapter 2: Introduction to C++.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Presentation transcript:

Introduction to Programming with RAPTOR

Objectives Use of the terminal symbol Use of the flow line Use of the input/output symbol Use of the process symbol Use of the decision symbol

What is RAPTOR? RAPTOR : Is a visual programming development environment based on flowcharts.

A flowchart A flowchart Is a collection of connected graphic symbols, where each symbol represents a specific type of instruction to be executed. The connections between symbols determine the order in which instructions are executed.

RAPTOR Program Structure A RAPTOR program : Is a set of connected symbols that represent actions to be performed. The arrows that connect the symbols, determine the order in which the actions are performed.

Executing a RAPTOR program When executing a RAPTOR program, you begin at the Start symbol and follow the arrows to execute the program. A RAPTOR program stops executing when the End symbol is reached. Start End

The smallest RAPTOR program By placing additional RAPTOR statements between the Start and End symbols you can create meaningful RAPTOR programs.

Introduction to RAPTOR Statements/Symbols RAPTOR has six (6) basic symbols. Each symbol represents a unique type of instruction.

Computer Program Components The typical computer program has three basic components: INPUT – get the data values that are needed to accomplish the task. PROCESSING – manipulate the data values to accomplish the task. OUTPUT – display (or save) the values which provide a solution to the task.

These three components have a direct correlation to RAPTOR instructions as shown in the following table.

RAPTOR Variables Variables : Are computer memory locations that hold a data value. At any given time a variable can only hold a single value. The value of a variable can vary (change) as a program executes. That's why we call them "variables"!

Example 1

Example 2

How to change the value of variable? A variable can have its value set (or changed) in one of three ways: By the value entered from an input statement. By the value calculated from an equation in an assignment statement. By a return value from a procedure call (more on this later).

Variable Name Meaningful and descriptive. Should relate to the purpose the variable serves in the program. Must start with a letter. Can contain only letters, numerical digits, and underscores (but no spaces or other special characters). If a variable name contains multiple "words," the name is more "readable" if each word is separated by an underscore character.

The table below shows some examples of good, poor, and illegal variable names: Good variable names Poor variable names Illegal variable names tax_rate sales_tax distance_in_miles mpg a (not descriptive) milesperhour (add underscores) my4to (not descriptive) 4sale (does not start with a letter) sales tax (includes a space) sales$ (includes invalid character)

Variable's Data Type A variable's data type cannot change during the execution of a program. In summary, variables are automatically created by RAPTOR and can hold either: Numbers e.g., 12, 567, -4, 3.1415, 0.000371, or Strings e.g., “Hello, how are you?”, “James Bond”, “The value of x is ”

Common errors when using variables: Error 1: "Variable ____ does not have a value“. There are two common reasons for this error: The variable has not been given a value. The variable name was misspelled.

The variable has not been given a value

The variable name was misspelled

Error 2: "Can't assign string to numeric variable _____" "Can't assign numeric to string variable _____"   This error will occur if your statements attempt to change the data type of a variable

RAPTOR Statements/Symbols Four basic statements: Input Statement. Assignment Statement. Call Statement. Output Statement.

Input Statement/Symbol An input statement/symbol allows the user of a program to enter a data value into a program variable during program execution. When you define an input statement, you must specify two things: a prompt . The variable that will be assigned the value enter by the user at run-time.

Input Statement/Symbol At run-time, an input statement will display an input dialog box. After a user enters a value and hits the enter key (or clicks OK), the value entered by the user is assigned to the input statement's variable.

Prompt Is a string of text that describes the required input. If the expected value needs to be in particular units (e.g., feet, meters, or miles) you should mention the units in the prompt. An Expression prompt enables you to mix text and variables together like the following prompt: “Enter a number between ” + low + “ and ” + high + “: ”.

Assignment Statement/Symbol The assignment symbol is used to perform a computation and then store the results in a variable.

Assignment Statement/Symbol An assignment statement is displayed inside its RAPTOR symbol using the syntax:

Assignment Statement/Symbol One assignment statement can only change the value of a single variable. If this variable did not exist prior to the statement a new variable is created. If this variable did exist prior to the statement. No variables on the right hand side of the arrow (i.e., the expression) are ever changed by the assignment statement.

Expressions The expression (or computation) of an assignment statement can be any simple or complex equation that computes a single value. An expression is a combination of values (either constants or variables) and operators. A computer can only perform one operation at a time.

Execution of the operations The operations are performed based on a predefined "order of precedence." For example, consider the following two examples: x ← (3+9)/3 x ← 3+(9/3)

Order of Precedence compute all functions. compute anything in parentheses. compute exponentiation (^,**) i.e., raise one number to a power. compute multiplications and divisions, left to right. compute additions and subtractions, left to right.

Operator & function An operator or function directs the computer to perform some computation on data. Operators are placed between the data being operated on (e.g. X/3). functions use parentheses to indicate the data they are operating on (e.g. sqrt(4.7) ).

Built-in operators and functions of RAPTOR Basic math: +, -, *, /, ^, **, rem, mod, sqrt, log, abs, ceiling, floor Trigonometry: sin, cos, tan, cot, arcsin, arcos, arctan, arccot Miscellaneous:random, Length_of

Assignment Statement/Symbol The result of evaluating an expression in an assignment statement: A single number. A single string of text.

Assignment Statement/Symbol You can also perform simple text manipulation by using a plus sign (+) to join two or more strings of text into a single string. You can also join numerical values with strings to create a single string. Full_name ← "Joe " + "Alexander " + "Smith" Answer ← "The average is " + (Total / Number)

Constants Constants are pre-defined variables whose values cannot be changed. RAPTOR defines several symbols that represent commonly used constants. You should use these constant symbols when you need their corresponding values in computations. pi is defined to be 3.14159274101257. e is defined to be 2.71828174591064.

Output Statement/Symbol An output statement displays a value to the MasterConsole window when it is executed. When you define an output statement, the "Enter Output" dialog box appear.

Output Statement/Symbol When you define an output statement, the "Enter Output" dialog box appear. If you include quote marks (") in the text, the quote marks will be displayed exactly as you typed them. If you include quote marks (") in the text, the quote marks will be displayed exactly as you typed them.

Output Statement/Symbol You can display multiple values with a single output statement by using building a string of text using the string plus (+) operator. When you build a single string from two or more values, you must distinguish the text from the values to be calculated by enclosing any text in quote marks (").

Output Statement/Symbol the quote marks are not displayed in the output window. For example, the expression, "Active Point = (" + x + "," + y + ")" will display the following if x is 200 and y is 5: Active Point = (200,5)

Display the results in a user-friendly manner This means you should display some explanatory text explaining any numbers that are output to the MasterConsole window.  

Non-user-friendly output Example Non-user-friendly output User-friendly output Example output: 2.5678 Example output: Area = 2.5678 square inches

Comments in RAPTOR Comments are used to explain some aspect of a program to a human reader, especially in places where the program code is complex and hard to understand. Comments mean nothing to the computer and are not executed

To add a comment to a statement Right-click your mouse over the statement symbol. Select the "Comment" line before releasing the mouse button. Enter the comment text into the "Enter Comment" dialog box.

Types of comments There are three general types of comments: Programmer header – documents who wrote the program, when it was written, and a general description of what the program does. (Add to the "Start" symbol) Section description – mark major sections of your program to make it easier for a programmer to understand the overall program structure. Logic description – explain non-standard logic.

Comments in RAPTOR Typically you should not comment every statement in a program.

Any Questions ?

Label the following RAPTOR identifiers as (G) good, (P) poor, or (I) Illegal. If illegal then explain why. ____ 1) This_Is_A_Test ____ 2) U_2 ____ 3) Money$ ____ 4) Thisisanawfullylongidentifiername ____ 5) Mickey-Mouse ____ 6) 365_Days ____ 7) Variable ____ 8) Is This Identifier Legal ____ 9) Why_Isn’t_This_One_Legal

Why are comments important? True or False. In RAPTOR, a variable does not have a value (in its memory location) until a program instruction gives it a value.

Calculate the result of the following expressions (or indicate if the expression contains errors). __________ 1) 46 / 2 __________ 2) 4 + 6 * 2 __________ 3) 12 / 3 / 2 __________ 4) (4 + 2) / (5 – 3) + 2 __________ 5) 46 / 3 __________ 6) 46 rem 3 __________ 7) 3(4 + 3) __________ 8) 6 ** sqrt(4) __________ 9) 77 + -11