ch2Probl

  • Upload
    dnlkaba

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

  • 7/28/2019 ch2Probl

    1/18

    Chapter 2- Visual Basic Schneider 1

    Chapter 2

    Problem Solving

  • 7/28/2019 ch2Probl

    2/18

    Chapter 2- Visual Basic Schneider 2

    Outl ine and Objective

    Program Development Cycle

    Programming Tools

  • 7/28/2019 ch2Probl

    3/18

    Chapter 2- Visual Basic Schneider 3

    Programming Languages:

    Machine Language

    Assembly Language

    High level Language

  • 7/28/2019 ch2Probl

    4/18

    Chapter 2- Visual Basic Schneider 4

    Machine Language

    The fundamental language of the computers

    processor, also called Low Level Language.

    All programs are converted into machine languagebefore they can be executed.

    Consists of combination of 0s and 1s that

    represent high and low electrical voltage.

  • 7/28/2019 ch2Probl

    5/18

    Chapter 2- Visual Basic Schneider 5

    Assembly Language

    A low level language that is similar to

    machine language.

    Uses symbolic operation code to represent

    the machine operation code.

  • 7/28/2019 ch2Probl

    6/18

    Chapter 2- Visual Basic Schneider 6

    High Level Language

    Computer (programming) languages that

    are easier to learn.

    Uses English like statements.

    Examples are C ++, Visual Basic, Pascal,

    Fortran and ....

  • 7/28/2019 ch2Probl

    7/18

    Chapter 2- Visual Basic Schneider 7

    Program Development Cycle:

    1. Analyze: Define the problem

    2. Design: Plan the solution to the problem

    3. Choose the Interface: Select the objects

  • 7/28/2019 ch2Probl

    8/18

    Chapter 2- Visual Basic Schneider 8

    Program Development Cycle:

    4. Code: Translate the algorithm into a

    programming language.

    5. Debug and Test: Locate and remove any

    errors in the program.

    6. Complete the Documentation: Organize all

    the materials that describe the program.

  • 7/28/2019 ch2Probl

    9/18

    Chapter 2- Visual Basic Schneider 9

    Programming Tools:

    Flowchart

    Pseudocode

    Hierarchy Chart (Structure chart)

  • 7/28/2019 ch2Probl

    10/18

    Chapter 2- Visual Basic Schneider 10

    What is a flowchart?

    Logic diagram to describe each step that the

    program must perform to arrive at the

    solution.

    A popular logic tool used for showing an

    algorithm in graphics form.

  • 7/28/2019 ch2Probl

    11/18

    Chapter 2- Visual Basic Schneider 11

    Continue flowchart

    Programmer prepares flowchart before

    coding.

    Most common flowchart symbols are:

  • 7/28/2019 ch2Probl

    12/18

    Chapter 2- Visual Basic Schneider 12

    Purpose of Flowcharting:

    An aid in developing the logic of a program.

    Verification that all possible conditions

    have been considered in a program.

    Provides means of communication with

    others about the program.

    A guide in coding the program.

    Documentation for the program.

  • 7/28/2019 ch2Probl

    13/18

    Chapter 2- Visual Basic Schneider 13

    Example of Flowchart:

    Start

    Initialize Counter =1

    and sum to 0

    Are there more data

    Get next grade

    Increment counter

    Add grade to sum

    Yes

    No

  • 7/28/2019 ch2Probl

    14/18

    Chapter 2- Visual Basic Schneider 14

    Desk Checking

    The process of testing the flowchart with different

    data as input, and checking the output.

    The test data should include nonstandard data as

    well as typical data.

  • 7/28/2019 ch2Probl

    15/18

    Chapter 2- Visual Basic Schneider 15

    What is a Pseudocode?

    A program design technique that uses

    English words.

    Has no formal syntactical rules.

  • 7/28/2019 ch2Probl

    16/18

    Chapter 2- Visual Basic Schneider 16

    Example of Pseudocode:

    Determine the average grade of a class:

    Do while there are more data

    Get the next Grade

    Add the Grade to the Sum

    Increment the Counter

    Loop

    Compute average = Sum / CounterDisplay average

  • 7/28/2019 ch2Probl

    17/18

    Chapter 2- Visual Basic Schneider 17

    What is a Hierarchy Chart?

    Shows the overall programs structure.

    Describes what each part, or module, of the

    program does.

    Also how each module relates to other

    modules in the program.

  • 7/28/2019 ch2Probl

    18/18

    Chapter 2- Visual Basic Schneider 18

    Example of Hierarchy Chart:

    Class average

    Program

    GetGrade

    CalculateAverage

    ComputeSum

    DisplayAverage