SHARE
TWEET

Untitled

a guest Jul 10th, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Chapter Four sample
  2. 'Ram raghuraman
  3.  
  4. 'Program No. 4.6
  5. 'Prints a list of attendees at a family reunion, showing name, age,
  6. 'average age, and number of persons in five age cohorts.
  7.  
  8. '               PROGRAM VARIABLES
  9. '
  10. '       Nam$                    NAME OF ATTENDEE
  11. '       Age                     AGE OF ATTENDEE
  12. '       Cohort1         AGE GROUP < 20
  13. '       Cohort2         AGE GROUP 20 – 39
  14. '       Cohort3         AGE GROUP 40 – 59
  15. '       Cohort4         AGE GROUP 60 – 79
  16. '       Cohort5         AGE GROUP > 79
  17. '       TotalAge                TOTAL OF AGES OF ATTENDEES
  18. '       TotalAtt                TOTAL NUMBER OF ATTENDEES
  19. '       AverAge         AVERAGE AGE OF ATTENDEES
  20. '      Head1$, Head2$  PRINT IMAGES
  21. '       Head3$, R$, W$,
  22. '       C$
  23.  
  24. '**************************  PROGRAM MAINLINE  ***********************
  25.  
  26. GOSUB InitializePrintImages
  27. GOSUB PrintHeadings
  28. GOSUB ProcessDetail
  29. GOSUB PrintSummary
  30. END
  31.  
  32. '*************************  INITIALIZE PRINT IMAGES  *******************
  33.  
  34. InitializePrintImages:
  35. LET HEAD1$ = "                  FOX FAMILY REUNION"
  36. LET HEAD2$ = "                  Attendance   -   1985"
  37. LET HEAD3$ = "          NAME                                    AGE"
  38. LET R$ = "           \                       \               ###"
  39. LET W$ = "                   AGE GROUPS                     NUMBER IN GROUP"
  40. LET C$ = "                  AVERAGE   AGE   OF   ATTENDEES      ##"
  41. RETURN
  42.  
  43. '***************************  PRINT   HEADINGS  ************************
  44.  
  45. PrintHeadings:
  46. PRINT HEAD1$
  47. PRINT HEAD2$
  48. PRINT
  49. PRINT
  50. PRINT HEAD3$
  51. PRINT
  52. RETURN
  53.  
  54. '*************************  PROCESS DETAIL  ***************************
  55.  
  56. ProcessDetail:
  57. CLS
  58. GOSUB InputAttendee
  59. DO UNTIL UCASE$(Nam$) = "END"
  60.     INPUT "ENTER AGE:                         ", Age
  61.     GOSUB CalculateTotals
  62.     GOSUB PrintDetailLine
  63.     GOSUB InputAttendee
  64. LOOP
  65. RETURN
  66.  
  67. '*************************  INPUT  ATTENDEE  **************************
  68.  
  69. InputAttendee:
  70. INPUT "ENTER NAME OF ATTENDEE (END to Quit):", Nam$
  71. RETURN
  72.  
  73. '************************  PRINT SUMMARY  ****************************
  74.  
  75. PrintSummary:
  76. GOSUB CalculateAverage
  77. PRINT
  78. PRINT USING R$; "NUMBER ATTENDING"; TotalAtt
  79. PRINT
  80. PRINT
  81. PRINT W$
  82. PRINT
  83. PRINT USING R$; "UNDER 20"; Cohort1
  84. PRINT USING R$; "20 - 39"; Cohort2
  85. PRINT USING R$; "40 - 59"; Cohort3
  86. PRINT USING R$; "60 - 79"; Cohort4
  87. PRINT USING R$; "OVER 79"; Cohort5
  88. PRINT
  89. PRINT USING C$; AverAge
  90. RETURN
  91.  
  92. '**********************  CALCULATE TOTAL  ****************************
  93.  
  94. CalculateTotals:
  95. LET TotalAtt = TotalAtt + 1
  96. LET TotalAge = TotalAge + Age
  97. IF Age < 20 THEN 'Age less than 20
  98.     LET Cohort1 = Cohort1 + 1
  99. ELSEIF Age > 19 AND Age < 40 THEN 'Age 20-39
  100.     LET Cohort2 = Cohort2 + 1
  101. ELSEIF Age > 39 AND Age < 60 THEN 'Age 40-59
  102.     LET Cohort3 = Cohort3 + 1
  103. ELSEIF Age > 59 AND Age < 80 THEN 'Age 60-79
  104.     LET Cohort4 = Cohort4 + 1
  105. ELSE
  106.     LET Cohort5 = Cohort5 + 1 'Age 80 and over
  107. END IF
  108. RETURN
  109.  
  110. '****************************  CALCULATE AVERAGE  *******************
  111.  
  112. CalculateAverage:
  113. LET AverAge = TotalAge / TotalAtt
  114. RETURN
  115.  
  116. '**********************  PRINT DETAIL LINE  ****************************
  117.  
  118. PrintDetailLine:
  119. PRINT USING R$; Nam$; Age
  120. RETURN
  121. '*************************  END OF PROGRAM   *************************
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top