CST 8128 — Lab 6 — Quiz

This Quiz is marked out of 18.  (The short-answer question is a 2-mark bonus.).  It contains two small programming problems worth 9 marks each, and one short-answer problem worth 2 marks.  You have 80 minutes to work on the problems; you must complete both programming problems by 11:20am.  The instructor will see demos between 11:20am and 11:50am.

Notes for programming:

Programming Marking Scheme:

Two Programming problems:

  1. Programming Problem (9 marks):

    Modify Example 7 in section 3.6 to prompt for an Algonquin Staff member's full name (first and last name) and generate the associated Internet email address.  The Staff email address is the first six characters of the last name, followed by one initial from the first name, followed by '@algonquincollege.com'.

    Your code must implement and use two functions:

    1. GetInitial(): takes a full name as its only argument and returns in lower-case form the letter that is the first initial of the first name.
    2. GetLast(): takes a full name as its only argument and returns in lower-case form the first six characters of the last name.

    Examples of full name input and Internet userid output:

    ian allen          idallen@freenet.carleton.ca
    SHAWN MCBRIDE      mcbrids@algonquincollege.com
    Lynne Rowe         rowel@algonquincollege.com
    JACQUES SAUCIER    sauciej@algonquincollege.com
    Richard Campbell   campber@algonquincollege.com
  2. Programming Problem (9 marks):

Do problem #18 on page 188 (population density), with the following modifications:

Write a new function named CalculateRawDensity() to calculate and return the floating-point raw population density when passed population and area as numeric arguments.

Write a second new function named CalulateWholeNumber() that takes a floating-point number as an argument, rounds it to the nearest whole number, and returns the result as an integer.

Have the CalculateDensity() subroutine call the above functions to do all the calculations for the population density problem. The functions themselves will not produce any output.   All output will be done by the CalculateDensity() subroutine, as is done in the text.

Modify the problem output so that the output also includes the number of people per square mile formatted with the standard two decimal points, as follows:

The density of Hawaii is 175 (175.36) people per square mile.
The density of Alaska is 1 (0.97) people per square mile.

One short answer problem:

Two marks (2 marks): Write down what the text gives as the four advantages of Structured Programming.

Quiz Rules:

You must answer this Quiz on your own, without assistance any from your classmates.   You may use your notes and your textbook, and any of your completed problem solutions, to help you.

No discussion or exchange of information between students is allowed during this Quiz.

You will have a minimum of 80 minutes to complete the solution to the assigned problems.  You may complete the problem in less time, demonstrate the solution to the instructor, and leave.  You may have more than 80 minutes to complete the solution if few enough students remain such that all remaining students can be marked in less than 30 minutes.

After at least 80 minutes have elapsed (at 11:20), the Quiz period is over.  The instructor will ask any remaining students to step away from the workstations.  He will select students who have not demonstrated their solutions and will have each student demonstrate one-at-a-time as much of the solution as is complete.  The Quiz mark will be based on whatever is completed at that time.

See the marking scheme, above.  Programming style (comments, indentation, layout) will be examined.  Programs that don't quite work, but are well written, are worth more than programs that work but lack comments and indentation.

Next week:

Read all of Chapter 5 on "Decisions" in preparation for next week.

New for Next Week: Weekly Log Sheet

To help you track your progress in the text, starting next week you will be asked to submit a Weekly Log Sheet listing the practice problems and exercises you completed while working on this week's section of the book.   (Practice problems and exercises are suggested in the Lab directions each week.)

Keep a written record of all the assigned problems or exercises you attempted so that you may enter this information into next week's Weekly Log Sheet.