lesson review1 itel460

Upload: orville-balangue

Post on 09-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 Lesson Review1 ITEL460

    1/42

    ITEL 460

    Intro to Computer Programming

  • 8/8/2019 Lesson Review1 ITEL460

    2/42

    Useful Terms

    Program Set of instructions that

    cause the computer to do

    something.

    Code Programming statements

    that you write. Compiler Converts code into

    something the computer can run.

  • 8/8/2019 Lesson Review1 ITEL460

    3/42

    Terms

    Application Files that have been

    compiled into an execution

    program

    Stored Program these are

    instruction

    splaced into thecomputers memory.

    Memory stores the data

  • 8/8/2019 Lesson Review1 ITEL460

    4/42

    Computer Programming the process of writing

    the sets of instructions that make up this job.

    Application Software Packages - Programs

    required for common business and personal

    applicationssuch as word processing or

    spread

    sheet

    scan be purcha

    sed from

    softwarevendors orstores that sell computer products.

  • 8/8/2019 Lesson Review1 ITEL460

    5/42

    Application Development the process of

    using programming language or

    development environment to build software

    applications.

    Project Files that you create that make up

    your applications. Control Tools that allow the program to

    interact with the user.

  • 8/8/2019 Lesson Review1 ITEL460

    6/42

    Bugs An error in the program

    Debug Correcting the errorsso theprogram will execute.

    Hardware The physical equipment

    of the computer.

    Software - Makes the computer

    useful.

  • 8/8/2019 Lesson Review1 ITEL460

    7/42

    Structured Programming

    Is a methodology used to facilitate translating

    the problem being analyzed.

    Known asModular Programming

    Is a subset of procedural programming thatenforces a logical structure on the program

    being written to make it more efficientand easier

    to understandand modify.

  • 8/8/2019 Lesson Review1 ITEL460

    8/42

    Flowchart

    Is a design tool used to represent the logic ina solution algorithm graphically.

    Each step in the process flow is represented

    by a differentsymbol and contain

    sa

    shorttext description of the processstep in the

    flow chart symbol.

  • 8/8/2019 Lesson Review1 ITEL460

    9/42

    Three basic control structure

    SEQUENCE SELECTION

    REPETITION

  • 8/8/2019 Lesson Review1 ITEL460

    10/42

    Sequence Control Structure

    Is used to show a

    single action or one

    action followed in

    order (sequentially) byanother.

    Actions can be input,

    processes, or output.

  • 8/8/2019 Lesson Review1 ITEL460

    11/42

  • 8/8/2019 Lesson Review1 ITEL460

    12/42

    Ex1:

    Total = PrelimGrade + MidtermGrade

    + SemifinalGrade + FinalGrade

    AverageG = Total/4

  • 8/8/2019 Lesson Review1 ITEL460

    13/42

    Ex2

    GrossPay = HoursWorked *

    HourlyRate

    Ded401K = GrossPay * 0.055

    Medicare = GrossPay * 0.0145

    SocSec = GrossPay * 0.0765

    TotDeductions = Ded401K +

    Medicare + SocSec

    NetPay = GrossPay - TotDeductions

  • 8/8/2019 Lesson Review1 ITEL460

    14/42

    Selection ControlStructure

    Is used to tell the program which action to take,

    based on a certain condition.

    When the condition is evaluated, its result either

    is true or false. If the result of the condition is true, one action is

    performed; if the result is false, a different action

    is performed.

  • 8/8/2019 Lesson Review1 ITEL460

    15/42

    selection control structure

    allows one set ofstatements to be

    executed if a condition is true andanotherset of actions to be executed

    if a condition is false.

  • 8/8/2019 Lesson Review1 ITEL460

    16/42

    Selection

    Structure

  • 8/8/2019 Lesson Review1 ITEL460

    17/42

    Selection

    Structure

  • 8/8/2019 Lesson Review1 ITEL460

    18/42

    Repetition Control Structure

  • 8/8/2019 Lesson Review1 ITEL460

    19/42

    Repetition Control Structure

  • 8/8/2019 Lesson Review1 ITEL460

    20/42

    Repetition Control Structure

  • 8/8/2019 Lesson Review1 ITEL460

    21/42

  • 8/8/2019 Lesson Review1 ITEL460

    22/42

  • 8/8/2019 Lesson Review1 ITEL460

    23/42

    Aselection structure, also called an "If-Then-

    Else" structure, is flowcharted as follows:

  • 8/8/2019 Lesson Review1 ITEL460

    24/42

    Repetition Control Structure

    Also called looping or iteration, is used when a

    set of actions is to be performed repeatedly.

    Looping is the process of repeatedly executingone or more steps of an algorithm or program; it

    is essential in programming, as most programs

    perform repetitious tasks.

  • 8/8/2019 Lesson Review1 ITEL460

    25/42

    Every loop consists of the following three parts:

    (1)The loop termination decision - determines when (underwhat condition) the loop will be terminated (stopped).

    It is essential that some provision in the program be madefor the loop to stop; otherwise, the computer would continue

    to execute the loop indefinitely - a loop that doesn't

    stop i

    scalled an endless loop or infinite loop.

    When a program getsstuck in an endless loop,programmerssay that the program is "looping".

  • 8/8/2019 Lesson Review1 ITEL460

    26/42

    (2)The body of the loop - the step orsteps of the algorithmthat are repeated within the loop. This may be only one

    action, or it may include almost all of the program

    statements.(3)Transfer back to the beginning of the loop - returns

    control to the top of the loop so that a new repetition

    (iteration) can begin.

  • 8/8/2019 Lesson Review1 ITEL460

    27/42

    Repetition Control Structure

  • 8/8/2019 Lesson Review1 ITEL460

    28/42

    Thewhile Repetition Structure

    Example:int product = 2;

    while ( product

  • 8/8/2019 Lesson Review1 ITEL460

    29/42

    The Program Development Life Cycle

    Is used to develop programs.

    Also called, system development cycle or

    system development life cycle.

    Analysis Phase

    Design Phase

    Code the Program

    Test and debug the Program

    Formalize the solution

    Maintain the Program

  • 8/8/2019 Lesson Review1 ITEL460

    30/42

    Pseudo Code

    Allows the programmer to focus on the

    steps required to solve the problem (

    rather than on how to use the

    programming language).

    Easy to translate into actual Visual Basic

    Code.

  • 8/8/2019 Lesson Review1 ITEL460

    31/42

    Advantages of Pseudo code

    It is compact

    Looks a lot like the code

    Easy to translate to actual code Preferred by many programmers.

  • 8/8/2019 Lesson Review1 ITEL460

    32/42

    Example1 (non-computer)

    Brush teeth

    Wash faceComb hair

    Smile in mirror

  • 8/8/2019 Lesson Review1 ITEL460

    33/42

    Ex2

    Ifstudent's grade is greater than or equal to 60

    Print "passed"else

    Print "failed"

  • 8/8/2019 Lesson Review1 ITEL460

    34/42

    Example 2

    READ height of rectangle

    READ width of rectangleCOMPUTE area as height times width

  • 8/8/2019 Lesson Review1 ITEL460

    35/42

    Example3

    IF HoursWorked > NormalMax THEN

    Display overtime message

    ELSE

    Display regular time message

    ENDIF

  • 8/8/2019 Lesson Review1 ITEL460

    36/42

    Ex3

    pseudocode for a bubble sort routinemight be written as:

    while not at end of listcompare adjacent elements

    ifsecond is greater than first

    switch them

    get next two elementsif elements were switched

    repeat for entire list

  • 8/8/2019 Lesson Review1 ITEL460

    37/42

    Common Action Keywords

    Several keywords are often used to indicate commoninput, output, and processing operations.

    Input:READ, OBTAIN, GET

    Output: PRINT, DISPLAY, SHOWCompute: COMPUTE, CALCULATE,

    DETERMINE

    Initialize: SET, INIT

    Add one: INCREMENT, BUMP

  • 8/8/2019 Lesson Review1 ITEL460

    38/42

    Exercises

    1. Write a program that obtains two integer

    numbers from the user. It will print out the

    sum of those numbers.

  • 8/8/2019 Lesson Review1 ITEL460

    39/42

    Pseudocode:

    Prompt the user to enter the first integer

    Prompt the user to enter a second integer

    Compute the sum of the two user inputs

    Display an output prompt that explains theanswer as the sum

    Display the result

  • 8/8/2019 Lesson Review1 ITEL460

    40/42

    Name:

    Subject:

    Topic: Pseudocode

    Specs:

    Write a program to calculate the cost of material for a dress. It will allow

    the user to enter the number of yards of material. The final cost will be

    displayed along with an appropriate output message.

    Use P 50.00 as cost per yard of the material. The final cost is the cost peryard times the number of yards as inputted by the user.

    You are guaranteed as a precondition that the user will enter a whole

    number between or including 1 and 100 only.

  • 8/8/2019 Lesson Review1 ITEL460

    41/42

    Pseudocode (answertoProb)

    the user inputs the number of yards of material into a text

    box and clicks a button

    store the user's input (# of yards) into an Integer variable

    multiply the number of yards by 50 and store that product ina Double variable

    display the final cost with an output prompt message

    allow the user to exit the program by clicking an Exit button

    at any time

  • 8/8/2019 Lesson Review1 ITEL460

    42/42

    E-references

    http://flint.cs.yale.edu/cs112/notes/L08six.

    pdf