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

CMSC 201 Fall 2018 Python Coding Standards

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

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

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

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

BASIC ELEMENTS OF A COMPUTER PROGRAM

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

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

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

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

Object-Oriented Programming

Lesson 3: Basic Programming Concepts

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

Creating a C++ Program

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

Simple Java Programming Constructs 4

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

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

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

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

More Programming Constructs -- Introduction

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

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

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

Quick Reference Guide

VARIABLES & ASSIGNMENTS

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

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

Python Unit

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

Chapter 2.5 Writing maintainable programs

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

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

Course Outline. Introduction to java

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

CS201 Some Important Definitions

SCoLang - Language Reference Manual

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

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

Add Subtract Multiply Divide

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

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

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

Lecture 3 Operators MIT AITI

Microsoft Visual Basic 2015: Reloaded

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

Lesson 6A Loops. By John B. Owen All rights reserved 2011, revised 2014

SECTION II: LANGUAGE BASICS

Basics of Java Programming

CSC Web Programming. Introduction to JavaScript

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

Variables and Operators 2/20/01 Lecture #

CEN 414 Java Programming

Topic 2: C++ Programming fundamentals

ENGR 101 Engineering Design Workshop

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

QUIZ: What value is stored in a after this

Level 3 Computing Year 2 Lecturer: Phil Smith

UNIT- 3 Introduction to C++

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

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

Introduction to the C++ Programming Language

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

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

Perl: Arithmetic, Operator Precedence and other operators. Perl has five basic kinds of arithmetic:

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

CSI Lab 02. Tuesday, January 21st

Introduction to C++ with content from

CS313D: ADVANCED PROGRAMMING LANGUAGE

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

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

Chapter 2. C++ Basics

Sprite an animation manipulation language Language Reference Manual

Programming for Engineers Iteration

Information Science 1

Programming for the Web with PHP

CS 211 Programming Practicum Fall 2018

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

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

LESSON 2 VARIABLES, OPERATORS, EXPRESSIONS, AND USER INPUT

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

Programming. C++ Basics

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1

Accelerating Information Technology Innovation

ENGINEERING 1020 Introduction to Computer Programming M A Y 2 6, R E Z A S H A H I D I

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

XSEDE Scholars Program Introduction to C Programming. John Lockman III June 7 th, 2012

CSCE 145 Exam 1 Review Answers. This exam totals to 100 points. Follow the instructions. Good luck!

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

Lecture 2: Variables and Operators. AITI Nigeria Summer 2012 University of Lagos.

Model Viva Questions for Programming in C lab

DATA AND ABSTRACTION. Today you will learn : How to work with variables How to break a program down Good program design

How to approach a computational problem

2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants

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 Homework All done? Turnitin L3U06H2PeterPan2016

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 Integer

Variables Naming conventions Should 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 Create a few slides that show how you declare global and local variables in the following languages: 1. Vb.net 2. Python 3. PHP Add to your slides how you would declare an array which contains the number of days for each month in a year, for each language.

Arrays Used to store a series of related values First value is numbered zero 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.

Homework: - submit to Turnitin L3U06H3PeterPan2016 In a presentation, explain how sequence, selection and iteration are used when writing programs. Based on your answers (i.e. the languages you used) in homework 2, give an example of each. If you use any images reference your images. (Hint: You discussed three languages in homework 2; you must provide an example of sequence, selection and iteration for each language).