BBS 514 - Yapısal Programlama (Structured Programming)1 From problem to program In “real world”… Problem in Natural language Top Down Design in pseudo-code.

Slides:



Advertisements
Similar presentations
4 Control Statements: Part 1.
Advertisements

PROBLEM SOLVING TECHNIQUES
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
BBS514 Structured Programming (Yapısal Programlama)1 Functions and Structured Programming.
 Control structures  Algorithm & flowchart  If statements  While statements.
Introduction to working with Loops  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming.
 2002 Prentice Hall. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 The if Selection Structure.
Introduction to Computers and Programming Lecture 8: More Loops New York University.
Program Design and Development
Introduction to Computers and Programming More Loops  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course.
Computer Science 1620 Programming & Problem Solving.
1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection Statement 4.6 if else Selection Statement 4.7 while.
Algorithms. Introduction Before writing a program: –Have a thorough understanding of the problem –Carefully plan an approach for solving it While writing.
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection.
Structured Program Development in C
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection.
Chapter 3 Planning Your Solution
Review Algorithm Analysis Problem Solving Space Complexity
The Art of Programming Top-Down Design. The Art of Problem Solving The art of problem solving is the transformation of an English description of a problem.
Adapted from slides by Marie desJardins
Introduction to Problem SolvingS1.2.1 Bina © 1998 Liran & Ofir Introduction to Problem Solving Programming in C.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Looping Exercises Deciding Which Loop to Use At this.
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
Looping While-continue.
General Programming Introduction to Computing Science and Programming I.
School of Computer Science & Information Technology G6DICP - Lecture 9 Software Development Techniques.
Structured Program Development Outline 2.1Introduction 2.2Algorithms 2.3Pseudo code 2.4Control Structures 2.5The If Selection Structure 2.6The If/Else.
CSE 102 Introduction to Computer Engineering What is an Algorithm?
Repetitive Structures BBS514 Structured Programming (Yapısal Programlama)1.
Repetition & Loops. One of the BIG advantages of a computer: ­It can perform tasks over and over again, without getting bored or making mistakes (assuming.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Practice and Evaluation. Practice Develop a java class called: SumCalculator.java which computes a sum of all integer from 1 to 100 and displays the result.
Computational Algorithms David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. lightning introduction.
PSEUDOCODE C Programming Technique – Firdaus-Harun.com.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
C Lecture Notes 1 Structured Program Development.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 4 - Control Structures: Part 1.
1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 The if Selection Structure 4.6 The if / else Selection Structure 4.7.
 Pearson Education, Inc. All rights reserved Control Statements: Part 1.
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection.
Unit 2 – Algorithms & Pseudocode. Algorithms Computer problems solved by executing series of action in order Procedure –The Actions to execute –The Order.
1 Lecture 3 Control Structures else/if and while.
Lecture 5: Stopping with a Sentinel. Using a Sentinel Problem Develop a class-averaging program that will process an arbitrary number of grades each time.
REPETITION STATEMENTS - Part2 Structuring Input Loops Counter-Controlled Repetition Structure Sentinel-Controlled Repetition Structure eof()-Controlled.
Chapter 7 Problem Solving with Loops
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
 2003 Prentice Hall, Inc. All rights reserved. 1 Will not cover 4.14, Thinking About Objects: Identifying Class Attributes Chapter 4 - Control Structures.
Intro to Loops 1.General Knowledge 2.Two Types of Loops 3.The WHILE loop 1.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Algorithms and Pseudocode
Lecture 5: Layers of Control. Nested while Loops Problem Multiplying two numbers and outputting the result only if they are both less than 5. (i.e. Start.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
Low-Level Programming Languages, Pseudocode and Testing Chapter 6.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 3 - Structured Program Development Outline.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Flow Control (while) Outline 3.7The While Repetition.
while Repetition Structure
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
Algorithms and Flowcharts
1) C program development 2) Selection structure
The while Looping Structure
Chapter 4 - Control Structures: Part 1
Basic Concepts of Algorithm
WJEC GCSE Computer Science
The while Looping Structure
Module 4 Loops and Repetition 9/19/2019 CSE 1321 Module 4.
Presentation transcript:

BBS Yapısal Programlama (Structured Programming)1 From problem to program In “real world”… Problem in Natural language Top Down Design in pseudo-code Program in computer code (code in almost any computer language.) Requirements: A program that does this and that and the other. It must take data from this source and IMPLEMENT Reduce cognitive load separating design and coding using top-down design The Problem Do this repeat if something then do this else do the other Print “all done” DESIGN The Design (Algorithm) The Program

BBS Yapısal Programlama (Structured Programming)2 Steps of Software Development 1.Problem Understanding –Read the problem carefully and try to understand what is required for its solution. 2.Analysis –Identify problem inputs and outputs. 3.Design –Develop a list of steps (algorithm) to solve the problem –Refine steps of this algorithm. (Divide and Conquer) –Verify that the algorithm solves the problem, i.e. the algorithm is correct. 4.Implementation –Implement the algorithm as a (java) program. –You have to know a specific programming language (java) –Convert steps of the algorithm into programming language statements. 5.Testing and Verification –Test the completed program, and verify that it works as expected. –Use different test cases (not one) including critical test cases.

BBS Yapısal Programlama (Structured Programming)3 Algorithm An algorithm is a design written in pseudo code. (in English, but a formal style) Algorithms contains: –Sequence –Decision –Repetition

BBS Yapısal Programlama (Structured Programming)4 Everyday Algorithms Problem: To drink a glass of milk. Algorithm: 1.Enter the kitchen 2.Get a glass 3.Get the milk from the refrigerator 4.Fill the glass with milk 5.Drink it Refine step 1: 1. Walk to the kitchen door 2. If the door is close then 2.T. Open it 3. Walk into the kitchen Refine step 3: 1. Open the refrigerator 2. Get the milk 3. Close the refrigerator Refine step 4: 1. while the glass is not full 1.1. Pour some milk into the glass

BBS Yapısal Programlama (Structured Programming)5 Area-Circumference Problem Requirements: Design an algorithm to find and report the area and circumference of a circle whose radius the user gives. Welcome to circle computer… Please enter the radius: 5 The area of a circle of radius 5 is and its circumference is Example interaction

BBS Yapısal Programlama (Structured Programming)6 Area-Circumference Problem To find area & circumference of circle… 1.Print welcome message 2.Ask for & get radius from user 3.Compute area as pi.radius.radius 4.Compute circumference as 2.pi.radius 5.Report area, circumference & radius Identify preconditions & ensure they are satisfied. Once we are sure that this is correct, move on to solve any non- trivial sub-problems.

BBS Yapısal Programlama (Structured Programming)7 Area-Circumference Problem (cont.) Solve… 5.Report area, circumference & radius 1.Print msg “The area of a circle with radius ” 2.Print radius value 3.Print msg “ is ” 4.Print area value and move to next line 5.Print msg “ and its circumference is ” 6.Print circumference value 7.Print blank line Solve… 2.Ask for & get radius from user 1.Ask (prompt) the user to enter radius 2.Get radius value from user

BBS Yapısal Programlama (Structured Programming)8 Calculating the average score of an exam Problem: Calculating the average score of an exam Inputs : Scores of an exam Output: Average score of the exam Algorithm: 1. Set count to zero 2. Set sum to zero 3. while there is an exam sheet do 3.1. Read the score on the sheet 3.2. Add the score on the sheet to sum 3.3. Add one to count 3.4. Move to the next sheet 4. Compute average as sum/count 5. Display average

BBS Yapısal Programlama (Structured Programming)9 Prime Number Problem: Deciding that a given integer number is prime or not. Input : An integer number N Output: A sentence indicating that N is prime or not. Algorithm: 1. Read the number N 2. Test whether N is prime or not 3. Display the result. Refine step 2: 1. set counter to 2 2. set PrimeFlag to true 3. while (counter < N and PrimeFlag = true) do 3.1. if N is divisible by counter then 3.1.T. set PrimeFlag to false 3.2. Increment counter by 1 Refine step 3: 1. if PrimeFlag = true then 1.T. Display that N is prime else 1.F. Display that N is not prime

BBS Yapısal Programlama (Structured Programming)10 Factorial Problem: Calculating N! Inputs: A positive integer N Output: N! Algorithm: 1. Read a positive integer N 2. Calculate NFactorial 3. Display NFactorial Refine step 2: 1. Set NFactorial to 1 2. Set counter to 2 3. while (counter <= N) do 3.1. Multiply NFactorial by counter 3.2. Increment counter by 1

BBS Yapısal Programlama (Structured Programming)11 Types & Layout (of algorithm steps) n.do step while condition indent 1.step 2.step 3.step 4.step Sequence n.if condition then nT step else nF step indent Decision n.while condition do step indent Repetition Any step can be replaced with one of the other types n.for so many times do step