Subject: Information Technology Grade: 10

Slides:



Advertisements
Similar presentations
ALGORITHMS AND FLOWCHARTS
Advertisements

Problem Solving INFORMATION TECHNOLOGY
ALGORITHMS AND FLOWCHARTS
Representing an algorithm using Flowcharts
Al-Karma Language School Computer Department Prep. 3.
Program Flowchart, Pseudocode & Algorithm development
Introduction to Flowcharting
Introduction to Flowcharting
PSEUDOCODE & FLOW CHART
Flow Control Analysis & Design Tool: Flowcharts
Understanding the Three Basic Structures
Chapter 3 IFTHENELSE Control Structure © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured.
Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Published by Addison-Wesley.
Computer Programming Rattapoom Waranusast Department of Electrical and Computer Engineering Faculty of Engineering, Naresuan University.
Fundamentals of Algorithms MCS - 2 Lecture # 4
ITEC113 Algorithms and Programming Techniques
Decisions (Conditional Programming) Chapter 5 (Sec. 5.1 & 5.2)
A High-Level Model For Software Development
Developing logic (Examples on algorithm and flowchart)
The Program Design Phases
(C)opyright 2003 Scott/Jones Publishers Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Scott/Jones Publishers.
Algorithm & Flowchart.
Chapter 1 Pseudocode & Flowcharts
ALGORITHMS AND FLOWCHARTS
CSC103: Introduction to Computer and Programming
DCT 1123 Problem Solving & Algorithms
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
Pseudocode Demo for Payroll.c
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
Problem Solving with Decisions
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
CHAPTER 3 SELECTION STRUCTURE.
1 CSC103: Introduction to Computer and Programming Lecture No 7.
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
BACS 287 Programming Logic 1. BACS 287 Programming Basics There are 3 general approaches to writing programs – Unstructured – Structured – Object-oriented.
Flowcharts and Algorithms. Review of Terms  A computer is a machine that can represent and manipulate data –Ultimately the data and the instructions.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
PROBLEM SOLVING WITH LOOPS Chapter 7. Concept of Repetition Structure Logic It is a computer task, that is used for Repeating a series of instructions.
ITEC113 Algorithms and Programming Techniques
Agenda Basic Logic Purpose if statement if / else statement
The IF-statements 31-Jan-2005 Venkatesh Ramamoorthy.
(C)opyright 2000 Scott/Jones Publishers Introduction to Flowcharting.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
Chapter 7 Problem Solving with Loops
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
Topics: Selection Statements. Processing Involving Selecting Instructions An instruction that allows deviation and selection to take place uses the ‘IF’
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
PROBLEM SOLVING. REDBLUE GREENPINK ORANGEYELLOW Exit.
ALGORITHMS AND FLOWCHARTS. A typical programming task can be divided into two phases: Problem solving phase  produce an ordered sequence of steps that.
Decisions: Conditional Statements (informally called If Statements) IST 256 Application Programming for Information Systems.
Introduction to Flowcharts
Lecture 2: Introduction to Programming EEE2108: 공학프로그래밍 서강대학교 전자공학과 2011 학년도 2 학기 - Algorithms and Flowcharts -
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
SELECTION CONTROL STRUCTURE Prepared by: Careene McCallum-Rodney.
ALGORITHMS AND FLOWCHARTS
Exercise : Write a program that print the final price of purchase at a store where everything costs exactly one dollar. Ask for the number of items purchased.
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
Algorithms and Flowcharts
2.0 Problem Solving PROGRAM DESIGN
Control Statement Examples
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
1) C program development 2) Selection structure
ALGORITHMS AND FLOWCHARTS
Introduction to Algorithms and Programming
Flowcharts and Pseudo Code
Developing a Program.
Presentation transcript:

Subject: Information Technology Grade: 10 Topics: Selection Statements

Processing Involving Selecting Instructions An instruction that allows deviation and selection to take place uses the ‘IF’ command. The IF statement contains a condition that is made up of three parts: Variable to be tested Relational operator Variable or constant to which the variable to be tested is compared to.

Relational Operators

If statements: IF-THEN IF-THEN-ELSE Flowchart Symbols: Decision making and branching Connector or joining two parts of a program. It is also used to connect sections of a flowchart when a flowchart is long and cannot fit on a page. A letter or digit can be placed in the small circle to indicate the link on the first page. Another identically labeled connector is placed on the next page to indicate the continuation of flow.

IF-THEN Pseudocode IF (condition) then When one option is available and a selection may or may not be made, the IF-THEN is used. Pseudocode IF (condition) then One or more instructions which will be carried out if the condition is true ENDIF

Flowchart no yes Condition Statement - True

Examples IF-THEN Problem 1: If a student’s grade is greater than 85%, then she is given 3 merits. Solution: Pseudocode IF (grade > 85) then merit = 3 ENDIF Flowchart no yes grade > 85 merit = 3

Problem 2: Read the time. If the time is 11:00, output “Ring the bell”. Solution Pseudocode Read time IF (time = 11) then Print “Ring the bell” ENDIF Flowchart Students is required to do the flowchart

Problem 3: Write a program to read a number N. If N is greater than or equal to 100, add 10 to the number and display the result. Print the number. Requirements: Write the Pseudocode Draw the flowchart

Pseudocode Start Declare N, result as Integer Print “A program that accepts a number, and if the number is greater than 100 then 10 is added to the number.” Print “Enter a number: ” Read N IF (N >= 100) then result = N + 10 Print “Result is ” result ENDIF Print “Number is ” N Stop

Print “Result is ”, result Flowchart START STOP Print “Enter a number” Read N N >= 100 Print “Result is ”, result result = N + 10 Print “Number is ”, N No Yes

Problem Write a program that calculates the total price of a ruler and a pencil. If the total price is more than $150, a discount of 5% is given. Compute and print the discount amount. Input the prices for the ruler and pencil and display the total price and the amount payable.

Requirements List the operations Write the Pseudocode Draw the Flowchart.

IF-THEN-ELSE When two options are available and a selection must be made, the IF-THEN-ELSE is used. Pseudocode IF (condition) then One or more instructions which will be carried out if the condition is true else One or more instructions which will be carried out if the condition is false ENDIF

Flowchart yes no Condition Statement - True Statement - False

Examples IF-THEN-ELSE Problem 1: If sales is greater than $7000, commission is $500 otherwise commission is $250 Solution: Pseudocode IF (sales > 7000) then commission = 500 else commission = 250 ENDIF Flowchart yes no Sales > 7000 Commission = 500 Commission = 250

Examples IF-THEN-ELSE Problem 2: Read the age of a person. If age is greater than 35, output “old person” otherwise output “young person” Solution: Pseudocode Read age IF (age > 35) then Print “Old person” else Print “Young person” ENDIF Flowchart Students is required to do the flowchart

Problem 3: Write a program that accepts employee’s salary. If the salary is less than or equal to $44000, then a bonus of 15% is given, otherwise 10% is given. Calculate and display the bonus amount given. Requirements: Write the Pseudocode Draw the Flowchart

Pseudocode Start Declare salary, bonus as Real Print “A program that accepts the salary for an employee, and calculate the bonus given” Print “Enter salary” Read salary IF (salary <= 44000) then bonus = salary * 0.15 else bonus = salary * 0.10 ENDIF Print “Bonus amount is ” bonus Stop

Flowchart STOP START Print “Enter salary” Read salary Print bonus = salary * 0.15 bonus = salary * 0.10 Yes No

Problem A credit union pays 4% interest on shares that are greater than $25000 and 3% on all other shares. No interest is paid on deposits. Write a program that prompts the user to input a share a deposit. The program should calculate and output the interest amount and the total savings (Total savings = shares + deposit + interest amount).

Requirements List the operations Write the Pseudocode Draw Flowchart

Home Work Cambridge – Information Technology for CSEC Exercise 22 – Numbers 1 - 5

THE END