End of a working day - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

End of a working day

Description:

Suppose it's the end of a working day. After 6pm on Fridays you go to the Manor Quay. ... go to the Manor Quay. loop. if driving. drink Coke. else. drink ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 10
Provided by: LindaS126
Category:
Tags: day | end | manor | working

less

Transcript and Presenter's Notes

Title: End of a working day


1
End of a working day
  • Produce PDL pseudocode corresponding to a single
    function which performs the following tasks
  • Suppose its the end of a working day.
  • After 6pm on Fridays you go to the Manor Quay.
  • If youre driving you drink Coke, if not you
    drink Beamish. At 11.30 you go home and go to
    bed.
  • If its not a Friday you work late before going
    home and making dinner. After dinner you watch TV
    and then go to bed.

2
function end_of_a_working_day calculate time and
day of week if Friday and after 6 p.m. go to
the Manor Quay loop if driving drink
Coke else drink Beamish ifend loopend
when its 1130 p.m. go home ifend
3
else work late go home make dinner watch
TV ifend go to bed function end
4
Back to the student marks program
  • First Cut
  • Structure Chart Student

  • Marks
  • Valid
    Stored
  • Marks
    Ranges
  • Accept Calculate
    Generate
  • Valid Marks Marks Range
    Graph
  • We now produce one low level diagram or PDL
    function for each of these 4 modules

5
PDL for student marks program
  • Remember that the program accepts pre-validated
    student marks and produces a graph showing the
    count for each of the ranges 0-10, 11-20,
    21-30, ..., 81-90, 91-100.
  • Stated assumptions the marks are input as whole
    numbers, and the graph is to be a bar chart of
    asterisks.
  • function Student Marks
  • set up data
  • valid marks lt- accept valid marks ( )
  • stored ranges lt- calculate marks range (valid
    marks)
  • generate graph (stored ranges)
  • function end

6
PDL for Accept Valid Marks
  • function Accept Valid Marks
  • set up data
  • write How many marks?
  • read number of marks
  • loop for each mark
  • read mark
  • if mark valid
  • write the entered mark
  • store mark
  • ifend
  • loopend
  • return the valid marks
  • function end

7
PDL for Calculate Marks Range
  • function Calculate Marks Range
  • set up data
  • loop for each mark
  • if mark gt 0 subtract 1 from mark
  • divide mark by 10 and ignore decimal
    part
  • to find the correct range array
    element
  • increment the range array element
  • loopend
  • return the stored ranges
  • function end

8
PDL for Generate Graph
  • function Generate_Graph
  • set up data
  • clear the screen
  • write graph title
  • loop for each range
  • calculate lower and upper boundaries
  • if lower boundary 1
  • lower boundary 0
  • ifend
  • display range boundaries
  • loop for each star
  • write
  • loopend
  • ifend
  • loopend
  • function end

9
Notes on PDL
  • See Sommerville p126 - 129
  • In principle, PDLs may be based on any
    programming language. Ada, a standard high level
    language in the defence industry, was designed
    for readability. It is therefore a good choice as
    a base language for a PDL.
  • PDLs, with elements of computer code and
    structured natural language, are a compromise
    between comprehensibility and precision.
Write a Comment
User Comments (0)
About PowerShow.com