Big Idea 3 · Topic 3.12 · Exercise 2
Effect or Value?
25 minutes - 5 calls - decide what each produces and what the program can reuse
Back to the Topic 3.12 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
PROCEDURE showItem(item, price) runs DISPLAY(item) then DISPLAY(price). The program runs the bare call showItem("Soda", 2).
Effect or value (does it DISPLAY or RETURN):
Exactly what appears on screen:
Enrichment - a subtler flow-of-control or return consideration:
Scenario 2 · Core
PROCEDURE costFor(count) runs RETURN(count * 3). The program runs total <- costFor(4).
Effect or value (does it DISPLAY or RETURN):
Exactly what appears on screen:
Enrichment - a subtler flow-of-control or return consideration:
Scenario 3 · Core
Using the same costFor(count) that runs RETURN(count * 3), the program runs the bare line DISPLAY(costFor(4)).
Effect or value (does it DISPLAY or RETURN):
Exactly what appears on screen:
Enrichment - a subtler flow-of-control or return consideration:
Scenario 4 · Challenge
The program runs count <- INPUT(), and the user types 5. Then it runs total <- costFor(count), where costFor(count) runs RETURN(count * 3).
Effect or value (does it DISPLAY or RETURN):
Exactly what appears on screen:
Enrichment - a subtler flow-of-control or return consideration:
Scenario 5 · Challenge
PROCEDURE mystery(count) runs RETURN(count * 3) and then, on the line after the RETURN, DISPLAY("done"). The program runs x <- mystery(2).
Effect or value (does it DISPLAY or RETURN):
Exactly what appears on screen:
Enrichment - a subtler flow-of-control or return consideration:
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.