Mark Dixon, SoCCE SOFT 131Page 1 04 – Information Processing: Expressions, Operators & Functions.

Slides:



Advertisements
Similar presentations
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Advertisements

Mark Dixon, SoCCE SOFT 131Page 1 22 – Object Oriented Analysis, Design, and Programming.
Mark Dixon Page 1 04 – Database Design: Forms. Mark Dixon Page 2 Session Aims & Objectives Aims –To allow easier data entry using forms Objectives, by.
Mark Dixon, SoCCE SOFT 136Page 1 05 – Conditional Execution.
Mark Dixon Page 1 06 – Expression Builder. Mark Dixon Page 2 Session Aims & Objectives Aims –To use expressions to perform more complex calculations in.
Mark Dixon, SoCCE SOFT 136Page 1 11 – User Defined Functions.
Mark Dixon, SoCCE SOFT 131Page 1 13 – Object Oriented Analysis, Design, and Programming.
Mark Dixon Page 1 02 – Dynamic HTML (client-side scripting)
The number of calories burned per hour by cycling, jogging and swimming are 200, 475 and 275 respectively. A person loses 1pound of weight for each 3500.
Mark Dixon, SoCCE SOFT 131Page 1 04 – Information Processing: Data-types, Variables, Operators & Functions.
Mark Dixon, SoCCE SOFT 131Page 1 19 – Procedure Parameters.
Python November 14, Unit 7. Python Hello world, in class.
Mark Dixon, SoCCE SOFT 131Page 1 02 – Software Development Lifecycle, & User Interface Design.
Mark Dixon, SoCCE SOFT 131Page 1 05 – Conditional Execution.
Mark Dixon Page 1 02 – Queries: Query by Example.
Mark Dixon, SoCCE SOFT 131Page 1 10 – User Defined Functions.
Mark Dixon, SoCCE SOFT 131Page 1 03 – Information Processing: Expressions, Operators & Functions.
Mark Dixon, SoCCE SOFT 131Page 1 04 – Conditional Execution.
Mark Dixon, SoCCE SOFT 131Page 1 12 – Enumerated Data-Types & Pass-by-reference.
Mark Dixon, SoCCE SOFT 131Page 1 13 – Control Arrays & Container Controls.
Mark Dixon, SoCCE SOFT 136Page 1 06 – Information Processing: Data-types, Constants, Variables.
Mark Dixon, SoCCE SOFT 131Page 1 09 – User Defined Procedures: Scope, and Parameters.
Mark Dixon, SoCCE SOFT 131Page 1 11 – Arrays of Structures & Modules.
Mark Dixon, SoCCE SOFT 131Page 1 05 – Information Processing: Data-types, Variables, Operators & Functions.
Mark Dixon Page 1 04 – Data Types. Mark Dixon Page 2 Admin: On-line Quiz.
Copyright © 2001 by Wiley. All rights reserved. Chapter 3: Variables, Assignment Statements, and Arithmetic Variables Assignment Statements Arithmetic.
Clearly Visual Basic: Programming with Visual Basic 2008
CS0004: Introduction to Programming Variables – Numbers.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using PhP.
M Dixon 1 04 – Data Types & Debugging. Questions: Expressions a)What is the result of: 7 + Int(8.245) b)Write an expression to: put a random number into.
Microsoft Visual Basic 2005 BASICS Lesson 4 Mathematical Operators.
Arithmetic operations and operators, converting data types and formatting programs for output. Year 11 Information Technology.
Visual Basic.NET BASICS Lesson 4 Mathematical Operators.
Mark Dixon, SoCCE SOFT 131Page 1 02 – Dynamic HTML (client-side scripting)
Mark Dixon, SoCCE SOFT 131Page 1 03 – Information Processing: Expressions, Operators & Functions.
7-1 Chapter 7.  Basic Arithmetic Verbs  Options Available with Arithmetic Verbs  COMPUTE Statement  Signed Numbers in Arithmetic Operations  Intrinsic.
New Project in Visual Basic Please use speaker notes for additional information!
Mark Dixon, SoCCE SOFT 131Page 1 05 – Variables. Mark Dixon, SoCCE SOFT 131Page 2 Admin: Test (next week) In class test –teaching week 6 –university week.
PRESENTATION 11 What Is Algebra. ALGEBRAIC EXPRESSIONS An algebraic expression is a word statement put into mathematical form by using variables, arithmetic.
Mark Dixon Page 1 05 – Problem Solving & Data Types.
Mark Dixon Page 1 03 – Dynamic HTML (client-side scripting)
3 1 Sending Data Using an Online Form CGI/Perl Programming By Diane Zak.
Mark Dixon Page 1 04 – Information Processing: Expressions, Operators & Functions.
Mark Dixon 1 03 – Information Processing. Mark Dixon 2 Questions: Events Consider the following code: a) How many unique events does it contain? b) Name.
Mark Dixon, SoCCE SOFT 131Page 1 24 – Datatypes and Object Association.
Mark Dixon, SoCCE SOFT 131Page 1 04 – Information Processing: Expressions, Operators & Functions.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
Mark Dixon Page 1 04 – Information Processing: Expressions, Operators & Functions.
Mark Dixon Page 1 04 – Information Processing: Expressions, Operators & Functions.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Mark Dixon Page 1 08 – Variables. Mark Dixon Page 2 Questions: Conditional Execution What is the result of (txtFah.value is 50): (txtFah.value >= 40)
Mark Dixon Page 1 08 – Variables. Mark Dixon Page 2 Questions: Conditional Execution What is the result of (txtFah.value is 50): (txtFah.value >= 40)
Hungarian Notation A must in this course Every object used MUST be renamed including the form(s) using the following rules Form  frmFormName E.g. frmTemperature.
Mark Dixon Page 1 05 – Problem Solving & Data Types.
Mark Dixon Page 1 04 – Conditional Execution. Mark Dixon Page 2 Questions: Expressions a)What is the result of: 10 * Int( ) b)How many functions.
110 E-1 Variables, Constants and Calculations(2) Chapter 3: Operations on variables, scope of a variable, formatting data Doing Arithmetic.
Slide 1 Controls v Control naming convention –Label: lblName –Command Button: cmdName –Text Box: txtName.
Mark Dixon Page 1 03 – Information Processing: Expressions, Operators & Functions.
Practical Programming COMP153-08S Arithmetic and Types.
Mark Dixon 1 13 – Parameters. Mark Dixon 2 Question: Arrays How many array variables are in the following code: Dim x Dim y Dim f(4) x = 12 y = 6 f(2)
Data and variables in Visual Basic. Annoucement Lecture on Thursday 7:30PM C106 Visual Basic download: 
Mark Dixon Page 1 03 – Information Processing: Expressions, Operators & Functions.
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.
Arithmetic operations and operators, converting data types and formatting programs for output. Year 11 Information Technology.
04 – Information Processing: Expressions, Operators & Functions
Introduction to Programming
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
Introduction to Programming
Presentation transcript:

Mark Dixon, SoCCE SOFT 131Page 1 04 – Information Processing: Expressions, Operators & Functions

Mark Dixon, SoCCE SOFT 131Page 2 Session Aims & Objectives Aims –Introduce you to main processing concepts, i.e. expressions, operators and functions Objectives, by end of this week’s sessions, you should be able to: –evaluate expressions –assign a value to a object's property, using combination of literal values, operators, functions, and identifiers

Mark Dixon, SoCCE SOFT 131Page 3 Information Processing All computing problems: –involve processing information/data information has meaning (e.g. 5lb 3.3kg 18 years) data has no meaning (e.g ) –following this pattern: For example: –to multiply two numbers: 7 * 9 = 63 Input DataProcessOutput Data *

Mark Dixon, SoCCE SOFT 131Page 4 Information Processing (cont.) Hence, to solve any computing problem ask: –what information goes in –what processing is done to it –what information comes out

Mark Dixon, SoCCE SOFT 131Page 5 Example: Multiply Option Explicit Private Sub btnMultiply_Click() lblResult.Caption = txtNum1.Text * txtNum2.Text End Sub lblResult btnMultiply txtNum1 txtNum2

Mark Dixon, SoCCE SOFT 131Page 6 The following assignment statement: lblResult.Caption = txtNum1.Text * txtNum2.Text contains an expression Expressions Given: txtNum1.Text = "7", txtNum2.Text = "9" can evaluate expression: lblResult.Caption = txtNum1.Text * txtNum2.Text (from above) lblResult.Caption = "7" * "9" (substitute) lblResult.Caption = 63 (calculate)

Mark Dixon, SoCCE SOFT 131Page 7 Expression Evaluation

Mark Dixon, SoCCE SOFT 131Page 8 Operators Sit between the data addition operatorresult is subtraction operatorresult is 3 5 * 2 multiplication operatorresult is 10 5 / 2 division operatorresult is 2.5 "5" & "2" string concatenationresult is "52" work with objects: txtNum1.Text * txtNum2.Text

Mark Dixon, SoCCE SOFT 131Page 9 Symbolic Representation Symbols (names) representing data txtNum1.Text = "33" Key concept in programming Puts 33 into txtNum1.Text The symbol txtNum1.Text now represents 33

Mark Dixon, SoCCE SOFT 131Page 10 Numeric Expressions txtNum1.Text * * 12 + txtNum1.Text d o o d o d txtNum1.Text + 1 – d o d o d d many people instinctively know these are wrong data operator data operator

Mark Dixon, SoCCE SOFT 131Page 11 String Expressions "What is " & num1 & " times " & num2 "What is twice " num1 & "?" "What is 6 minus " & & num & "?" data operator data operator ERROR! missing data ERROR! missing operator

Mark Dixon, SoCCE SOFT 131Page 12 Example: AddNum v1 Option Explicit Private Sub btnAdd_Click() lblResult.Caption = txtNum1.Text + txtNum2.Text End Sub lblResult btnAdd txtNum1 txtNum2

Mark Dixon, SoCCE SOFT 131Page 13 Types of Information Numbers (numeric)29 (integer/whole) (decimal/real) Text (string)"Hello there!" "BOO" Pictures Sound

Mark Dixon, SoCCE SOFT 131Page 14 AddNum problem The + operator works with: –numbers, and –text Double Quotes " used in VB to show literal text Text input boxes store text = 39 "23" + "16" = "2316"

Mark Dixon, SoCCE SOFT 131Page 15 Functions & Operators Used to: –process (manipulate) data Both Functions & Operators: –take input data/parameters (1 or more item) –process it –return a result which replaces the expression (substitution) Parameter(s) Result SQR Function (16)4

Mark Dixon, SoCCE SOFT 131Page 16 Functions (cont.) Functions: come before the data (which is in brackets) Sqr(16) square rootresult is 4 Abs(-23) absolute valueresult is 23 Int(2.543) integerresult is 2 CInt("63") integer convertresult is 63 Left("boo",2) left stringresult is "bo" Right("hello",3) right stringresult is "llo" Mid("hello",2,2) middle stringresult is "el"

Mark Dixon, SoCCE SOFT 131Page 17 Questions: Expressions What is the result of: 1 + CInt("23") + Int( ) + Sqr(Int(9.4523)) What is the result of: "23" & "18" + Left("bob",1) + Right("sal",2) Write an expression to: give integer value of " " Write an expression to: give the first two letters of "Mr John Smith" = 29 "23" & "18" & "b" & "al" = "2318bal" Int(CInt(" ")) Left("Mr John Smith", 2)

Mark Dixon, SoCCE SOFT 131Page 18 Example: AddNum v2 Option Explicit Private Sub btnAdd_Click() lblResult.Caption = CInt( txtNum1.Text ) + CInt( txtNum2.Text ) End Sub

Mark Dixon, SoCCE SOFT 131Page 19 Tutorial Exercises Task 1: get the multiply example (from the lecture) working Task 2: get the addnum examples v1 and v2 (from the lecture) working Task 3: create a project with two text boxes (surname and forenames), and a button (initials). When the button is clicked the first character from each text box (i.e. the person's initials) should be displayed. Task 4: create a new page that helps the user covert from Pounds to Dollars Go on-line and look up the current exchange rate Task 5: modify your currency converter, so that the result is displayed to 2 decimal places, e.g. $62.45 (you will need to use the Format function, look it up in the help system for an explanation) Task 6: modify your currency converter, replace the dollar label with a text box, and add another button that converts the dollar value back to pounds. Task 7: modify your currency converter, so that when the user types into the pounds text box only the appropriate button is enabled.