DEFINE THE PROBLEM - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

DEFINE THE PROBLEM

Description:

define the problem – PowerPoint PPT presentation

Number of Views:61
Avg rating:3.0/5.0
Slides: 19
Provided by: Blai97
Category:

less

Transcript and Presenter's Notes

Title: DEFINE THE PROBLEM


1
  • DEFINE THE PROBLEM

2
Analysis of the Problem
  • 1. Determine what is given - input
  • gtnouns, adjectives
  • 2. Determine what is required - output
  • gtnouns, adjectives
  • 3. Determine the transformations
    needed(processing)
  • -actions needed to produce the required output
  • gtverbs, adverbs

3
Inputs and Outputs
  • Determine data that is input to the problem, data
    that will be output from the problem
  • Nouns
  • We call the input and output data-variables
  • We use a particular naming convention
  • No spaces
  • Meaningful names
  • Usually begin with lowercase
  • Examples roomWidth, numPeople, studentName

4
Example 1
Read three numbers, add them together and print
the total. Read three numbers, add them together
and print the total. Step 1 define inputs and
outputs(hint look at nouns) Break up several
values into separate variables
5
Example 1
Read three numbers, add them together and print
the total. Read three numbers, add them together
and print the total. Step 2 define list of
actions. Hint Use verbs,these steps usually
involve the input and output defined in step 1
6
Example 2
Write a program to prompt the operator for the
maximum and minimum temperature readings on a
particular day, accept those readings as
integers, and calculate and display on the screen
the average temperature.
7
Example 2
Write a program to prompt the operator for the
maximum and minimum temperature readings on a
particular day, accept those readings as
integers, and calculate and display on the screen
the average temperature.
8
  • PLAN THE SOLUTION

9
Plan the Solution
  • Outline the Solution
  • Major processing steps involved
  • Major subtasks
  • Major control structures
  • Major variables and record structures
  • Mainline logic
  • Develop the outline into an algorithm
  • Test the algorithm for correctness

10
Structured Programming
  • Top Down Design Development
  • Modularity
  • Control structures
  • sequence
  • selection or IF-THEN-ELSE
  • repetition or looping

11
Design/Plan the solution
  • Algorithm a step by step procedure for solving
    a problem
  • Programs - implementations of algorithms
  • Set of instructions
  • flowcharts
  • pseudocode
  • test solution for correctness - trace

12
Pseudocode
  • structured concise English statements used to
    state operations
  •  language independent,no standard
  •  use words and phrases that are in line with
    basic computer operations
  •  

13
Pseudocode
  • Write statements in simple English
  • Write each instruction on a separate line.
  • Use keywords and indentation for control
    structures.
  • Write instructions from top to bottom, with only
    one entry and one exit.
  • Groups of statements may be formed into modules.

14
Pseudocode
  •  1. Input - receiving information
  •  keywords - Read, Get, Input
  •  Read - receive information from a record on a
    file
  • Get - receive information from the keyboard.
  • Read studentName
  • Get systemDate
  • Read num1,num2
  • Get taxCode
  •  use one verb followed by one or more nouns

15
Pseudocode
  • 2. Output
  • putting information out
  • Put, Output,Display - screen
  • Print - printer
  • Write - file
  • Print smaller.
  • Print "Program Completed"
  • Write customer_record to file
  • Output totalTax
  • Display "End of Data"

16
Output continued
  • Labels
  • Display "label"
  •  statement inside quotes is printed as it appears
  • Display "x" // if x 5
  • Yields x
  • Display x
  •  yields 5
  •  Display "X " and x
  •  yields X 5

17
Pseudocode
  • 3. Arithmetic
  •  use name of the operation or algebraic symbol
  •  add,subtract,multiply, divide, exponentiation
  •   - /
  •  x algebraic expression
  • count count 1
  • netPay hourlyPayRate hoursWorked
  • salesTax cost 0.10
  • totalPrice price salesTax

18
Pseudocode
  • 4. Assignment - place information into a storage
    location
  •  Initialize, Set - give variable initial value
  • Save,Store - save info for later
  •   //preferred
  • y 3 note does not mean equality
  • could involve calculation
  • area length width
  •   
Write a Comment
User Comments (0)
About PowerShow.com