Program Development Cycle and Flowcharts PDF

Summary

This document describes the program development life cycle, including designing programs, writing code, fixing errors, and understanding tasks. It also explains different tools like pseudocode and flowcharts.

Full Transcript

Copyright © 2018 Pearson Education, Inc. Designing a Program Programs must be designed before they are written Program development cycle: Design the program Write the code Correct syntax errors Test the program Correct logic errors Copyright © 2018...

Copyright © 2018 Pearson Education, Inc. Designing a Program Programs must be designed before they are written Program development cycle: Design the program Write the code Correct syntax errors Test the program Correct logic errors Copyright © 2018 Pearson Education, Inc. Designing a Program (cont’d.) Design is the most important part of the program development cycle Understand the task that the program is to perform Work with customer to get a sense of what the program is supposed to do Ask questions about program details Create one or more software requirements (a task the program must perform) Copyright © 2018 Pearson Education, Inc. Designing a Program (cont’d.) Determine the steps that must be taken to perform the task Break down required task into a series of steps Create an algorithm, listing logical steps that must be taken Algorithm: set of well-defined logical steps that must be taken to perform a task Copyright © 2018 Pearson Education, Inc. Pseudocode Pseudocode: fake code Informal language that has no syntax rule Not meant to be compiled or executed Used to create model program No need to worry about syntax errors, can focus on program’s design Can be translated directly into actual code in any programming language Copyright © 2018 Pearson Education, Inc. Flowcharts Flowchart: diagram that graphically depicts the steps in a program Ovals are terminal symbols Parallelograms are input and output symbols Rectangles are processing symbols Symbols are connected by arrows that represent the flow of the program Copyright © 2018 Pearson Education, Inc. Basic Flowcharting Symbols Copyright © 2018 Pearson Education, Inc. Copyright © 2018 Pearson Education, Inc. Input, Processing, and Output Typically, computer performs three-step process Receive input Input: any data that the program receives while it is running Perform some process on the input Example: mathematical calculation Produce output Copyright © 2018 Pearson Education, Inc. The Sales Price Example Problem: A local department store wants to develop a program which, when given an item’s original price and the percentage it is discounted, will compute the sale price with sales tax. Output required: name of item, discounted price, amount of sales tax, total price Variables needed: ItemName, SalePrice, Tax, TotalPrice Input required: name of item, original price, percent discounted More variables: OriginalPrice, DiscountRate Formulas required: New variable needed: AmountSaved SalePrice = OriginalPrice – AmountSaved AmountSaved = OriginalPrice * (DiscountRate/100) Tax = SalePrice *.065 TotalPrice = SalePrice + Tax Copyright © 2018 Pearson Education, Inc. E.g. Designing the program using a chart Input 🡪 Processing 🡪 Output Input Perform Calculations (Process) Output :Input Variables :Computations :Display ItemName AmountSaved = OriginalPrice * DiscountRate/100 TotalPrice DiscountRate SalePrice = OriginalPrice – AmountSaved ItemName OriginalPrice Tax = SalePrice *.0654 Tax TotalPrice = SalePrice + Tax SalePrice Copyright © 2018 Pearson Education, Inc. Pseudocode Example: pseudocode for the Sale Price Program: Input Data module Prompt for ItemName, OriginalPrice, DiscountRate Input ItemName, OriginalPrice, DiscountRate Perform Calculations module Set AmountSaved = OriginalPrice * (DiscountRate/100) Set SalePrice = OriginalPrice – AmountSaved Set Tax = SalePrice *.065 Set TotalPrice = SalePrice + Tax Output Results module Write ItemName Write OriginalPrice Write DiscountRate Write SalePrice Write Tax Write TotalPrice Copyright © 2018 Pearson Education, Inc. Comparison of Pseudocode and Flowchart for Sales Price Program Input Data Prompt for ItemName, OriginalPrice, DiscountRate Input ItemName, OriginalPrice, DiscountRate Perform Calculations Set AmountSaved = OriginalPrice * (DiscountRate/100) Set SalePrice = OriginalPrice – AmountSaved Set Tax = SalePrice *.065 Set TotalPrice = SalePrice + Tax Output Results Write ItemName Write OriginalPrice Write DiscountRate Write SalePrice Write Tax Write TotalPrice Copyright © 2018 Pearson Education, Inc. Classwork Create the IPO chart and write the Pseudocode for the following program: Design a program that will prompt a salesperson for their name, sales for the month in dollars and their commission rate expressed as a percent. The program will calculate the commission for that month. The program should make use of the Input, Process and Output steps. Use the following variables: SalesPersonName, SalesAmount, CommissionRate, CommissionEarned. Use the following formula: CommissionEarned = SalesAmount * CommissionRate/100 The output should appear as follows: SalesPersonName your sales are: $SalesAmount and your commission is: $CommissionEarned Copyright © 2018 Pearson Education, Inc.

Use Quizgecko on...
Browser
Browser