Big Idea 3 · Topic 3.13 · Exercise 2
Design the Procedure
25 minutes - 5 tasks - decide the header, the body, and whether it RETURNs
Back to the Topic 3.13 lessonAll CSP topics
How this page works
The writing boxes below are yours. What you type stays in this browser, is saved here as you go, and is never sent to us or to your teacher. Hand the written work in the way your teacher asked for it.
The graded check at the bottom is the part that records to your teacher's gradebook.
The cases, from your handoutNot recorded
The same cases as your handout, in the same order.
Scenario 1 · Foundational
The store needs a procedure that takes a unit price and a quantity and gives back the total so the caller can add it to a running cart total.
Header (name + parameters):
RETURN a value or DISPLAY only? Why:
Enrichment - a subtler design choice (guard, single job, hidden internals):
Scenario 2 · Core
The store needs a procedure that prints a product's name and price on a label. Nothing else in the program uses the result - the whole point is what appears on screen.
Header (name + parameters):
RETURN a value or DISPLAY only? Why:
Enrichment - a subtler design choice (guard, single job, hidden internals):
Scenario 3 · Core
The store gives free samples: a procedure takes a price and a quantity, but if the quantity is 0 it should immediately give back 0 without doing any multiplication.
Header (name + parameters):
RETURN a value or DISPLAY only? Why:
Enrichment - a subtler design choice (guard, single job, hidden internals):
Scenario 4 · Challenge
The store needs a procedure that gives back a discounted price: it takes a price and a discount, and returns price minus discount - but a discount can never make the price go below 0.
Header (name + parameters):
RETURN a value or DISPLAY only? Why:
Enrichment - a subtler design choice (guard, single job, hidden internals):
Scenario 5 · Challenge
A teammate wants to speed up lineTotal from Task 1 by rewriting HOW it computes the total, but every call in the program must keep working unchanged. Describe what they may change and what they must keep.
Header (name + parameters):
RETURN a value or DISPLAY only? Why:
Enrichment - a subtler design choice (guard, single job, hidden internals):
No graded check on this page yetNot recorded
About the line in your handout
Your handout says this exercise is available online and auto-graded. The exercise IS here, and it is the same work in the same order, but the auto-graded half is not written for this topic yet. Nothing on this page is scored or sent to your teacher.
Hand this in the way your teacher asked for it. Topic 1.1 has its graded check today, and the rest follow.