Lecture 1: Subject Introduction and Overview on Structured Programming Approach PDF
Document Details
Uploaded by TidyIndium
Tags
Related
- Software Development Basics PDF
- Computer Science Algorithms and Problem Solving 2015 PDF
- Introduction to Programming and Problem Solving (CS101) Lecture 1 PDF
- CSC 1029 Week 5 Class Session: Software Development Lifecycle PDF
- Unit 02: Computational Thinking and Algorithms PDF
- Software Programming Chapter 10 PDF
Summary
This document provides an introduction to structured programming, outlining the steps of the software development method, pseudocode, and flowcharts. It also includes examples of different programming operations.
Full Transcript
Lecture 1 Subject Introduction and Overview on Structured Programming Approach Learning Outcomes Students will be able to: Identify the steps of the software development method Solve problems using the two learned methods – Pseudocode – Flowchart...
Lecture 1 Subject Introduction and Overview on Structured Programming Approach Learning Outcomes Students will be able to: Identify the steps of the software development method Solve problems using the two learned methods – Pseudocode – Flowchart Page 2 of 27 The Software Development Method Programming is a problem-solving activity The objective of this lecture is to improve your problem- solving ability Problem-solving methods are covered in many areas – Business → systems approach – Engineering → engineering and scientific method – Programming → software development method Page 3 of 27 … The Software Development Method Specifying the problem requirements Analyse the problem Design the algorithm to solve the problem Implement the algorithm Test and verify the completed program Maintain and update the program Page 4 of 27 … The Software Development Method Specifying the problem requirements To gain a clear understanding of what is required for its solution It can be done by interview the target user or through observation This step is not as easy to achieve as it sounds, you may find you need extra information Page 5 of 27 … The Software Development Method Analyse the problem Involves identifying the problem – Input the data you have to work with – Output the desired results – Process formula to solve the problem, you may require additional requirements or constraints Page 6 of 27 … The Software Development Method Design the algorithm to solve the problem Algorithm a finite list of steps for solving a problem 2 popular ways to represent algorithm – Pseudocode – Flowchart Pseudocode Statements in human language that follow loosely defined syntax that are used to convey the design of an algorithm Flowchart Program design tool in which standard graphical symbols are used to represent the logical flow of data Desk checking the step-by-step simulation of the computer execution of an algorithm Think aloud Page 7 of 27 How to Write Pseudocode Based on six basic computer operations – Computer can receive information – Computer can put out information – Computer can perform arithmetic – Computer can assign a value to a variable or memory location – Computer can compare two variables and select one out of two alternatives – Computer can repeat a group of actions Page 8 of 27 … How To Write Pseudocode Computer can receive information Receive info or input from a particular source Normal verbs used – Read input from record in a file – Get input from keyboard Examples – Read student name – Get system date Page 9 of 27 … How To Write Pseudocode Computer can put out information Supply information or output to a device Normal verbs used – Print output to be sent to printer – Write output to be written to a file – Put, Output, Display output to be displayed on screen Examples – Print ‘Program Completed’ – Write customer record to master file – Output total cost – Display ‘End of Program’ Page 10 of 27 How To Write Pseudocode Computer can put out information Normal verbs used – Prompt causes message to be sent to screen asking for user’s input Example – Prompt for student_name Page 11 of 27 …How To Write Pseudocode Computer can perform arithmetic Perform mathematical calculation, apply a formula etc Normal verbs and symbols used – Add or + – Subtract or – – Multiply or * – Divide or / – ( ) parentheses Examples – Divide total_marks by student_count – Sales_tax = cost_price * 0.1 – Compute C = (F-32) * 5/9 Page 12 of 27 …How To Write Pseudocode Computer can assign a value to a variable or memory location Normal verbs and symbols used – Set or Initialise to give data an initial value – = or to assign as a result of some processing – Save or Store to keep a variable for later use Examples – Initialise total_price to zero – Set Student_count to 0 – total_price = cost_price + sales_tax – total_price cost_price + sales_tax – Store student_num in last_student_num Page 13 of 27 How to Draw Flowchart Start/End Input/Output Process Condition Flow Lines Connector Page 14 of 27 Desk Checking Choose sample data as input Determine the expected output Run through the algorithm to check the flow Think aloud Page 15 of 27 … The Software Development Method Implement the algorithm In this step, you must convert each algorithm step into one or more statements in a programming language Page 16 of 27 … The Software Development Method Test and verify the completed program Testing and verifying the program requires testing the completing program to verify that it works as desired Run the program several times using different sets of data to make sure that it works correctly for every situation Page 17 of 27 … The Software Development Method Maintain and update the program Maintaining and updating the program involves modifying a program to remove previously undetected errors and to keep it up-to-date as company policies change A programmer should create programs that are easy to read, understand and maintain Always give appropriate and meaningful comments in your program Page 18 of 27 Case Study: Converting Miles to Kilometers Specifying the problem requirements – Your summer surveying job requires you to study some maps that give distances in kilometers and some that use miles. You and your co-workers prefer to deal in metric measurements. Write a program that performs the necessary conversion. Page 19 of 27 … Case Study: Converting Miles to Kilometers Analyse the problem Input → the distance in miles Output → the distance in kms based on the user input Process → 1 mile = 1.609 kms Formula: distance_kms distance_miles * 1.609 – Assumption user input is greater than 0 – Abstraction the process of modeling a problem by extracting the essential variables and their relationship Page 20 of 27 … Case Study: Converting Miles to Kilometers Design the algorithm to solve the problem Step 1: Step 2: Refinement 1.0 start 1.0 start 2.0 get the distance in miles, miles 2.0 get the distance in miles, miles 3.0 convert the distance to kms 3.0 convert the distance to kms 4.0 display the distance in kms, 3.1 kms 1.609 * miles kms 4.0 display the distance in kms, 5.0 end kms 5.0 end Sample input Expected Output 10.00 16.090000 Do desk checking!!! Page 21 of 27 … Case Study: Converting Miles to Kilometers Implement the algorithm Algorithm 1.0 start 2.0 get the distance in miles 3.0 convert the distance to kms 3.1 kms = 1.609 * miles 4.0 display the distance in kms 5.0 end Page 22 of 27 … Case Study: Converting Miles to Kilometers Test and verify the completed program Always examine program results carefully to make sure that they make sense Enter a few test values of miles. Page 23 of 27 Learning Outcomes Now, you must be able to: Identify the steps of the software development method. Utilize pseudocode & flowchart for problem solving Page 24 of 27 Exercises List ALL steps in the software development method By applying step 1, 2 and 3 in software development method, solve the following problem: – Compute and display the total cost of apples given the number of kilograms of apples purchased and the cost per kilogram of apples. Page 25 of 27