Unit 6 - Software Design and Development LESSON 3 KEY FEATURES

Similar documents
Unit 6 - Software Design and Development LESSON 3 KEY FEATURES

Unit 6 - Software Design and Development LESSON 4 DATA TYPES

Unit 3. Operators. School of Science and Technology INTRODUCTION

Fundamentals. Fundamentals. Fundamentals. We build up instructions from three types of materials

Chapter 2 Working with Data Types and Operators

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Introduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4.

BASIC ELEMENTS OF A COMPUTER PROGRAM

Compilation and Execution Simplifying Fractions. Loops If Statements. Variables Operations Using Functions Errors

Lesson 3: Basic Programming Concepts

Computer Components. Software{ User Programs. Operating System. Hardware

Programmers should write code that is self-documenting and split into small sections.

Simple Java Programming Constructs 4

Lesson 3: Arithmetic & Casting. Pic 10A Ricardo Salazar

Introduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

BoredGames Language Reference Manual A Language for Board Games. Brandon Kessler (bpk2107) and Kristen Wise (kew2132)

More Programming Constructs -- Introduction

9691 COMPUTING. 9691/23 Paper 2 (Written Paper), maximum raw mark 75

COMSC-051 Java Programming Part 1. Part-Time Instructor: Joenil Mistal

Computer Programming, I. Laboratory Manual. Experiment #2. Elementary Programming

VARIABLES & ASSIGNMENTS

Sir Muhammad Naveed. Arslan Ahmed Shaad ( ) Muhammad Bilal ( )

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.

Programming for Engineers Iteration

Creating a C++ Program

Chapter 2.5 Writing maintainable programs

CSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York

Object-Oriented Programming

Course Outline. Introduction to java

CS201 Some Important Definitions

9/5/2018. Overview. The C Programming Language. Transitioning to C from Python. Why C? Hello, world! Programming in C

SCoLang - Language Reference Manual

The C Programming Language. (with material from Dr. Bin Ren, William & Mary Computer Science)

Add Subtract Multiply Divide

CMSC 201 Fall 2018 Python Coding Standards

Chapter 2 REXX STATEMENTS. SYS-ED/ Computer Education Techniques, Inc.

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.

Quick Reference Guide

Lecture 3 Operators MIT AITI

Mobile Computing Professor Pushpendra Singh Indraprastha Institute of Information Technology Delhi Java Basics Lecture 02

Microsoft Visual Basic 2015: Reloaded

Unit-II Programming and Problem Solving (BE1/4 CSE-2)

Class 2: Variables and Memory. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)

Basics of Java Programming

REVIEW. The C++ Programming Language. CS 151 Review #2

CSC Web Programming. Introduction to JavaScript

Variables and Operators 2/20/01 Lecture #

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

ENGR 101 Engineering Design Workshop

To become familiar with array manipulation, searching, and sorting.

UNIT- 3 Introduction to C++

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

Level 3 Computing Year 2 Lecturer: Phil Smith

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

Chapter Overview. C++ Basics. Variables and Assignments. Variables and Assignments. Keywords. Identifiers. 2.1 Variables and Assignments

SAMS Programming A/B. Lecture #1 Introductions July 3, Mark Stehlik

Lesson 02 Working with Data Types. MIT 31043: VISUAL PROGRAMMING By: S. Sabraz Nawaz Senior Lecturer in MIT

CS313D: ADVANCED PROGRAMMING LANGUAGE

Sprite an animation manipulation language Language Reference Manual

Introduction to C++ with content from

What is PHP? [1] Figure 1 [1]

GO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one.

PRG PROGRAMMING ESSENTIALS. Lecture 2 Program flow, Conditionals, Loops

Data types Expressions Variables Assignment. COMP1400 Week 2

C++ Programming: From Problem Analysis to Program Design, Third Edition

Programming. C++ Basics

Python Unit

Full file at C How to Program, 6/e Multiple Choice Test Bank

Introduction to Java & Fundamental Data Types

Pupil Name. Year. Teacher. Target Level. Key Stage 3 Self-Assessment Year 9 Python. Spelling Test No 3. Spelling Test No 2. Spelling Test No 1

I. Variables and Data Type week 3

Microsoft Visual Basic 2005: Reloaded

CEN 414 Java Programming

Python as a First Programming Language Justin Stevens Giselle Serate Davidson Academy of Nevada. March 6th, 2016

Introduction to the C++ Programming Language

Operators. Java operators are classified into three categories:

Fundamental of Programming (C)

Expressions. Arithmetic expressions. Logical expressions. Assignment expression. n Variables and constants linked with operators

YOLOP Language Reference Manual

SECTION II: LANGUAGE BASICS

Arithmetic Operators. Binary Arithmetic Operators. Arithmetic Operators. A Closer Look at the / Operator. A Closer Look at the % Operator

Lecture 3 Tao Wang 1

CSCI 1100L: Topics in Computing Lab Lab 11: Programming with Scratch

Fundamentals of Programming

Building Applications

Lesson 02 Working with Data Types MIT 31043, Visual Programming By: S. Sabraz Nawaz

Lab 1: Input, Processing, and Output This lab accompanies Chapter 2 of Starting Out with Programming Logic & Design.

SOURCE LANGUAGE DESCRIPTION

LESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:

Professor: Sana Odeh Lecture 3 Python 3.1 Variables, Primitive Data Types & arithmetic operators

Chapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.

Chapter 3: Operators, Expressions and Type Conversion

Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

6.096 Introduction to C++ January (IAP) 2009

Flow Control. CSC215 Lecture

CSI Lab 02. Tuesday, January 21st

CSC 120 Computer Science for the Sciences. Week 1 Lecture 2. UofT St. George January 11, 2016

Transcription:

Unit 6 - Software Design and Development LESSON 3 KEY FEATURES

Last session 1. Language generations. 2. Reasons why languages are used by organisations. 1. Proprietary or open source. 2. Features and tools. 3. Availability of trained staff. 4. Reliability. 5. Development and maintenance costs. 6. Expandability

What is covered in this session Key features of programming languages

Features of programming Assignment 3 requires you to write a computer program. In order to write this program we need to understand key features of programming. These key features apply to all programming languages.

sequence; selection eg Features of programming case, if then else; iteration eg repeat until, while.. do; variables eg naming conventions, local and global variables, logical operators; assignment statements; input statements; output statements

Code Structures It is important to have a logical structure to programs. Programs should be organized so developers and maintainers can easily determine what modules and routines perform what function. In procedural paradigms the logical structure follows a top down approach.

Code sequences In all programming languages, irrespective of programming paradigms, code must be executed in sequence. One line at a time. This is the order of execution (the order in which the code runs).

Code sequences Normal code will run line by line. In VB.NET, the program starts with the public class. In Scratch, the program starts at the top and works downwards.

Task 10 Use Visual Studio to Create a new (Visual Basic) VB.net Windows forms application name this U06Exercise1. You should have a blank form in the design window. Now do Lab04 part a (only part a). What result did you get?

Selection statements Selection is about decision making in your code. break the line-by-line reading tell the program to jump to another section. An example of this would be an IF statement. In VB.NET, you can make use of for loops and if statements. In Scratch, you can also use loops if a criteria is/isn t true.

Selection statements If statements check for a true condition and then execute the dependant statements. If a = b then.. End if Is this true? If so, do this!

Selection statements What do these statements do? 1. If x > 0 and x < 5 then Console.writeline(x.tostring) End if 2. If x > 0 then if x < 5 then End if End if Console.writeline(x.tostring)

Selection statements Add a button to your form named btnselection, the text should say Selection Add a numericupdown control named numnumber. Change its max value property to 100. Now do Lab04 Part b. Make sure you add comments to the code.

Case statements An alternative way to code multiple If/elseif Statements.

Case statements. Example of If/elseif If x = 0 then console.writeline(x.tostring()) Elseif x = 1 then console.writeline(x.tostring()) Elseif x = 2 then console.writeline(x.tostring()) etc

Example of If/elseif replaced with case. Select Case x Case 0 console.writeline(x.tostring()) Case 1 console.writeline(x.tostring()) Case 2 console.writeline(x.tostring()) End Select This is easier to read and maintain.

Case statements Add a button to your form named btncase, the text on the button should read Case. Do Lab04 Part c. Comment the code. Is this code easier to read than that in part b?

Iteration statements. (Loops) Iteration in computing is the repetition of a block of statements within a computer program. Two types of loop. Fixed loops a sequence of statements is executed a fixed number of times. Dim ant as int32 = 0 For ant = 0 to 5.. Do something Loop An assignment statement

Iteration statements. (Loops) The second type is a loop which continues until a condition is met or continues while a condition is true. Do while x > 0 and x < 5. Loop Example of a pre-check loop condition

Loops Add a button to your form named btnloop, the text on the button should read Loop. Do Lab04 Part d. Comment the code.

Increment/decrement statements Consider these statements Dim x as int32 = 0 x = x + 1 what is the value of x? As an alternative we could do this x++ this produces the same result as the line above. However, it only increments by 1.

Increment/decrement statements Consider these statements Dim x as int32 = 0 x = x - 1 what is the value of x? As an alternative we could do this x-- this produces the same result as the line above. However, it only decrements by 1.

Increment/decrement statements Consider these statements Dim x as int32 = 12 x = x + 1 what is the value of x? As an alternative we could do this x++ this produces the same result as the line above. It still only increments by 1.

Assignment statements Assign values to variables use = or := E.g. myvariable = 20 Can be combined with mathematical operator E.g. myvariable = 20 + subtotal

Mathematical Operators myvariable = 20 + 2 * 3 What answer will this produce? Why? BIDMAS Operator Meaning Example Precedence ^ Exponentiation 2^3=8 1 / Division 10/2=5 2 * Multiplication 2*3=6 3 Mod Modular arithmetic (remainders) 5(mod)2=1 4 + Addition 4+5=9 5 - subtraction 7-4=3 6

Input and output statements In visual programming input and output usually accomplished by controls. List boxes; text boxes; buttons Procedures collect values entered into boxes E.g. MyText = txtmyinput.text variable textbox

Input and output statements Similarly for output Procedures enter values into boxes E.g. lblmylabel.text = mytext label variable String value could also be used.

Variables Data input into a program must be stored Stored in defined memory areas variables Temporary storage for data used in processing Source of data for data output Temporary lost when program ends If needed as permanent data must be saved as output to files.

Variables Name allocated by programmer to give identity within the program Naming conventions must be adhered to Data type defines sort of data to be stored Normally declared (created) at beginning of program E.g. in Vb.net Dim variable_name As data-type Dim student_name As string

Variables Naming conventions start with a letter (not a number) Can contain any combination of letters and numbers No spaces Can be upto 255 characters in length Cannot use any symbols (except underscore_) Cannot use any reserved words (e.g. PRINT) Should be meaningful to aid editing

Variables When declaring variables you cannot use reserved words. These reserved words are elements of the language syntax and therefore would confuse the compiler if variables were allowed to be named the same as syntax keywords

Local and Global Variables Most programs split into sections Procedures; sub-routines; modules Variables normally declared within a section Can only be accessed and used in that section. These are local variables.

Local and Global Variables Can declare variables to be accessed and used across entire program Global variables. Vb.net declared at top of program before any subroutine, use Public Shared instead of Dim e.g. Public Shared Grand_Total as Integer Not considered good practice but sometimes can t be avoided Can lead to problems due to confusion and misunderstanding especially in large projects with teams of programmers

Variables Task 11 Refer to the programme created for lab04 Create a short presentation to explain some Key features of programming languages Collect code snippets to show: Sequence Selection Iteration Use these code snippets to illustrate what each of these terms means.

Arrays Used to store a series of related values First value is numbered zero Dim age_0 as integer Dim age_1 as integer Dim age_2 as integer Dim age_3 as integer Dim age_4 as integer Dim age_n as integer Dim age(n-1) as integer A six-element array from age(0) to age(5) We could be here sometime writing this lot out

Array declarations VB.net Dim intcalendardays() As Int32 = {31, 28, 31, 30} ' etc Python calendardays = [31,28,31,30,..] Php $calendardays = array(31,28,31,30,.);

Logical operators Used by selection statements Boolean logic AND both conditions must be met OR only one condition needs to be met NOT reverses the input, often used in emergency stop routines.