Any Questions! 2 Agenda Moving data Arithmetic Verbs Compute statement.

Slides:



Advertisements
Similar presentations
7-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Advertisements

Chapter 3 Math Vocabulary
RATIONAL EXPONENTS Assignments Assignments Basic terminology
 It is the numerical factor that contains a variable.  In other words, it is a number in a math sentence that has a letter right by it.
Whole Numbers.
Scientific Notation Why Do We Need It?.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
Pharmacology I Math Review.
Agenda  Commenting  Inputting Data from Keyboard (scanf)  Arithmetic Operators  ( ) * / + - %  Order of Operations  Mixing Different Numeric Data.
Chapter 5 Using Data and COBOL Operators. Initializing Variables When you define a variable in WORKING- STORAGE, you also can assign it an initial value.
Multiplying and Dividing Decimals by 10, 100, and 1,000
7-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
Lecture 31 Numeric Edited Alphabetic (A) AlphaNumeric (X) Numeric (9, V, S) Numeric Edited (9, Z, comma, decimal point, minus sign) –Z = zero suppressed.
Significant Figures Rules and Applications. Rules for Determining Significant Figures 1.) All Non-Zero digits are Significant. 1.) All Non-Zero digits.
7-1 Chapter 7.  Basic Arithmetic Verbs  Options Available with Arithmetic Verbs  COMPUTE Statement  Signed Numbers in Arithmetic Operations  Intrinsic.
Operations with Positive Fractions
Order of Operations.
PRESENTATION 11 What Is Algebra. ALGEBRAIC EXPRESSIONS An algebraic expression is a word statement put into mathematical form by using variables, arithmetic.
1.2 Algebraic Expressions 8/24/12. Vocabulary Variable: A letter used to represent one or more numbers Exponent: The number or variable that represents.
Lecture 41 Arithmetic Clauses The ROUNDED clause –Place ROUNDED after the variable that holds the result ADD A TO B ROUNDED. ADD A TO B GIVING C ROUNDED.
More Syntax in COBOL  Moving Data  Selection Statements  System Date  Indicators in Display files.
Arithmetic and Edited Pictures. Arithmetic Verb Template  Most COBOL arithmetic verbs conform to the template above. For example; ADD Takings TO CashTotal.
Module 6 Arithmetic. Arithmetic Verb Template  Most COBOL arithmetic verbs conform to the template above. For example; ADD Takings TO CashTotal. ADD.
Divide. Evaluate power – 3 = – 3 EXAMPLE – 3 = 3 2 – – 3 = 6 – 3 Multiply. Evaluate expressions Multiply and divide from.
Any Questions!. Test Coming Up! Agenda Printing with Externally Described Printer Files Arrays.
7-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Chapter 8 – Exponents and Exponential Functions 8.1/8.3 – Multiplication and Division Properties of Exponents.

Warm-up, 3/28 Compute: 1. 2 x 2 x 2 x 2 = 2. 3 x 3 x 3 = 3. 2 x 2 x 3 x 3 x 3 = 4. 5 x 5 x 2 x 2 = 5. 2 x 2 x 4 =
1-2 Order of Operations and Evaluating Expressions.
Significant Figure Rules RulesExamples The following are always significant Non zero digits Zeros between non zero digits Zero to the right of a non zero.
1 Chapter 5 – The Procedure Division File handling statements –OPEN statement Initiates processing for a file Input Output Each file opened must have been.
1.3 Solving Linear Equations
Any Questions? Agenda Level 77 Initialize Display & Accept Arithmetic Verbs Compute statement String/Unstring Inspect.
Assignment statement: Assigns a value to a variable Variable must appear on the left side, value on the right side of the assignment operator Right side.
Chapter 3 Arithmatic Operations 3.1 Operators An operator is a symbol or world that represents some operation that is performed on one or more data values.
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions Chapter 7.
Renaming Fractions as Decimals The trick to this is to get the fraction in a base divisible by The denominator is in base 10. The zeros in the.
Any Questions? Week 1 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
Arithmetic Operators. Operators In Programming Most computer programming languages use the following symbols for their operators: +  add -  subtract.
This is It! It’s been a pleasure! Final Exam – format True / false 5 Multiple choice 5 Short answers10 Data manipulation10 SQL 3 Array’s12 File processing25.
ORDER OF OPERATIONS. What is the correct method for solving numerical problems?
Addition Multiplication Subtraction Division. 1.If the signs are the same, add the numbers and keep the same sign = = If the.
Significant Figures. Significant Figure Rules 1) ALL non-zero numbers (1,2,3,4,5,6,7,8,9) are ALWAYS significant. 1) ALL non-zero numbers (1,2,3,4,5,6,7,8,9)
Operators A binary operator combines two values to get one result: x OP y where OP is any binary operators such as +, -, *, /, ==, !=, >, &&, or even =.
ORDER OF OPERATIONS LESSON 2.
Notes 2.1 Order of Operations PEMDAS If an expression has only numbers and symbols, it is a numerical expression. If it has a variable it is a variable.
Mental Math Everyone Take out a sheet of paper and Number your page = = = = = =
The Order of Operations The Order of Operations Objective: Use the order of operations and grouping symbols.
Click the mouse button or press the Space Bar to display the answers.
Assignment statement:
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Arithmetic operations & assignment statement
Quantitative Measurements
REALLY BIG & REALLY small Numbers
Chapter 3 The DATA DIVISION.
ALGEBRA. ALGEBRA VARIABLES AND EXPRESSIONS Algebra – Uses symbols to represent quantities that are unknown or that vary. You can represent mathematical.
RATIONAL EXPONENTS Basic terminology Substitution and evaluating
Two Step Equation.
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
THE COMPUTE STATEMENT Purpose: performs mathematical calculations
You replace it with its simplest name
Two step equation Operations
Operators In Java Programming By Rajanikanth B.
Two step equation Brackets
Any Questions?.
Multiply and divide Expressions
What do you think it means? Before:
Order of Operations  + - X.
By: Savana Bixler Solving Equations.
Presentation transcript:

Any Questions!

2 Agenda Moving data Arithmetic Verbs Compute statement

MOVE COBOL assignment verb MOVE name TO first-name.

4 THE MOVE STATEMENT PROCESS-RECORDS. MOVE EMP-NAME TO DET-NAME MOVE EMP-HOURS TO DET-HOURS 01 EMPLOYEE-IN. 05 EMP-NAME 05 EMP-HOURS 05 EMP-RATE 05 EMP-DEP 01 DETAIL-LINE. 05 FILLER 05 DET-NAME 05 FILLER 05 DET-HOURS 05 FILLER 05 DET-PAY 05 FILLER

5 THE MOVE STATEMENT PROCESS-RECORDS. MOVE EMP-NAME TO DET-NAME MOVE EMP-HOURS TO DET-HOURS Source contents assigned to destination variable Specific rules to do the move Move is just a copy, source does not change Equivalent to C assignments

6 Move Statement MOVE Identifier/Variable or Literal/Constant TO (Indentifier/Variable)s

7 Permissible Moves

8

9

10 Non-Permissible Moves

Numeric Moves Sending FieldReceiving Field Okay?Numeric –Field sizes NumericAlphanumeric –Decimal places –Packed fields Numeric Group Item

12 MOVE numeric TO numeric. Field A PIC 9(3) Field B PIC 9(3) 100 Field A PIC 9(3)Field B PIC 9(4) 100 Field APIC 9(3) Field B PIC 9(2) 100

13 MOVE numeric TO numeric. Field A PIC 9(3)V99 Field B PIC 99V Field A PIC 9(3)V99 Field B PIC 9(4)V Field A PIC 9(3)V99 Field B PIC 9(3)

14 MOVE numeric TO alphanumeric. Field A PIC 9(3) Field B PIC X(3) 100 Field A PIC 9(3) Field B PIC X(4) 100 Field A PIC 9(3) Field B PIC X(2) 100

15 MOVE numeric TO alphanumeric. Field A PIC 9(3)V99 Field B PIC X(3)

16 MOVE numeric TO group item Field A PIC 9(3)Field B. Field C PIC 99. Field D PIC 9. Field AField BField CField D 124

17 MOVE numeric TO group item Field A PIC 9(3)Field B. Field C PIC 99. Field D PIC 99. Field AField BField CField D 124

18 MOVE numeric TO group item Field A PIC 9(3)Field B. Field C PIC 9. Field D PIC 9. Field AField BField CField D 124

Alphanumeric Moves Sending FieldReceiving Field Okay? Alphanumeric Numeric –Decimal Places –Packed fieldsAlphanumeric –Field sizes Alphanumeric Group Item

Zero Moves Sending FieldReceiving Field Okay? ZerosNumeric ZerosAlphanumerics ZerosGroup Item

Spaces Moves Sending FieldReceiving Field Okay? SpacesNumeric Spaces Alphanumerics Spaces Group Items

MOVE numeric TO group item Field A PIC 9(3)Field B. Field C PIC XX. Field D PIC X. Field AField BField CField D 124

MOVE numeric TO group item Field A PIC 9(3)Field B. Field C PIC XX. Field D PIC XX. Field AField BField CField D 124

MOVE numeric TO group item Field A PIC 9(3)Field B. Field C PIC X. Field D PIC X. Field AField BField CField D 124

MOVE alphanum TO alphanum. Field APIC X(3) Field B PIC X(3) CJM Field A PIC X(3)Field BPIC X(4) CJM Field APIC X(3) Field BPIC X(2) CJM

MOVE alphanum TO group item Field A PIC X(3)Field B. Field C PIC XX. Field D PIC X. Field AField BField CField D CJM

MOVE alphanum TO group item Field A PIC X(3)Field B. Field C PIC XX. Field D PIC XX. Field AField BField CField D CJM

MOVE alphanum TO group item Field A PIC X(3)Field B. Field C PIC X. Field D PIC X. Field AField BField CField D CJM

MOVE alphanum TO numeric. Field APIC X(3) Field B PIC 9(3) ABC

MOVE zeros TO numeric. Field B PIC 9(3) Field BPIC 9(4)V99

MOVE zeros TO alphanumeric. Field B PIC X(3) Field BPIC X(1)

MOVE zero TO group item Field B. Field C PIC 99. Field D PIC 9. Field BField CField D

MOVE zeros TO group item Field B. Field C PIC XX. Field D PIC XX. Field BField CField D

MOVE spaces TO numeric. Field B PIC 9(3) Field BPIC 9(4)V99 Note: This is not supposed to work!

MOVE spaces TO alphanumeric. Field B PIC X(3) Field BPIC X(1)

MOVE spaces TO group item Field B. Field C PIC 99. Field D PIC 9. Field BField CField D Note: this is not supposed to work!

MOVE spaces TO group item Field B. Field C PIC XX. Field D PIC XX. Field BField CField D

On your own, figure out how Group Item to Group Item and Group Item to Alphanumeric work!

39 Arithmetic Verbs Add, Subtract, Multiply and Divide ALL can use SCOPE-TERMINATORS

40 Add Verb Three Formats: ADD variable/constant variable/constant ….. TO variable [ROUNDED] …. ADD variable/constant variable/constant …...… GIVING variable [ROUNDED] ADD variable/constant variable/constant ……. TO variable/constant GIVING variable [ROUNDED]

41 ADD Verb A = 100B = 50 C = 300 ADD A to B A = B = C = ADD A to B GIVING C A = B = C = What would happen if C was PIC 9(2)? ADD A B GIVING C ROUNDED A = B = C = What would happen if C was PIC 9(2)?

42 SUBTRACT Verb Two Formats: SUBTRACT Variable/Constant Variable/Constant... FROM Variable [ROUNDED] SUBTRACT Variable/Constant Variable/Constant … FROM Variable GIVING Variable [ROUNDED]

43 SUBTRACT Statement A = 100 B = 50C = 150D = 200 SUBTRACT A B FROM C A = B = C = D = SUBTRACT A B FROM C GIVING D A = B = C = D =

44 MULTIPLY Statement More restrictive Two Formats MULTIPLY variable/constant BY variable…. MULTIPLY variable/constant BY variable/constant GIVING variable …...

45 MULTIPLY Statement A = 50 B = 100C = 20 D = 500 MULTIPLY A BY B A = B = C = MULTIPLY A BY B C A = B = C = MULTIPLY A BY B GIVING C D A = B = C =

46 DIVIDE Statement More restrictive Three Formats DIVIDE variable/constant INTO variable …. DIVIDE variable/constant INTO variable/constant [GIVING variable …..] DIVIDE variable/constant BY variable/constant GIVING variable …...

47 DIVIDE Statement A = 100B = 50C = 25 D = DIVIDE A INTO B D A =B = C = DIVIDE A INTO B GIVING C D A =B = C = DIVIDE A BY B GIVING C A = B = C =

48 REMAINDER Clause Two formats: DIVIDE variable/constant INTO variable/constant GIVING variable REMAINDER variable DIVIDE variable/constant BY variable/constant GIVING variable REMAINDER variable

49 REMAINDER Clause A = 100 B = 150C = 20D = 10 DIVIDE A INTO B GIVING C REMAINDER D. A = B = C = D =

50 Clauses that work with all arithmetic statements.

51 Rounding Add the ROUNDED option to the end of the math statement. Eg. DIVIDE A INTO B GIVING C ROUNDED.

52 ON SIZE ERROR option What to do if the resulting value from the Mathematical Expression is too big for the result variable. Used to Resolve Divide by Zero errors. ADD A B GIVING C ON SIZE ERROR PERFORM ERROR-HANDLING-ROUTINE.

53 Compute Statement Combines all of the math verbs plus exponentiation

54 The COMPUTE Statement COMPUTE DET-PAY = EMP-HOURS * EMP-RATE Cobol provides: Addition + or ADD Subtraction - or SUBTRACT Multiplication * or MULTIPLICATION Division/ or DIVIDE Exponentiation ** COMPUTE can combine all of them Or you can use individual verbs (ADD 1 TO MYCUNTER)

55 Compute Statement Symbols

56 Order of Operations Operations in brackets ( ) are performed first ** (exponentiation) * or / (from left to right) + or - (from left to right)

57 Compute Statement A = 10B = 2C = 60 D is PIC 9(4) COMPUTE D ROUNDED = A ** B / ( A - B) + C. What is the value of D?