Title: DEFINE THE PROBLEM
1 2Analysis 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
3Inputs 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
4Example 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
5Example 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
6Example 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.
7Example 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 9Plan 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
10Structured Programming
- Top Down Design Development
- Modularity
- Control structures
- sequence
- selection or IF-THEN-ELSE
- repetition or looping
11Design/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
12Pseudocode
- structured concise English statements used to
state operations - language independent,no standard
- use words and phrases that are in line with
basic computer operations -
13Pseudocode
- 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.
14Pseudocode
- 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
15Pseudocode
- 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"
16Output 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
17Pseudocode
- 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
18Pseudocode
- 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
-