CSC 1001 — Lab 2: Problem Solving with Pseudocode
Intro
This lab is entirely about pseudocode — no code today. You'll start by comparing two given solutions individually, then write your own pseudocode for a new problem, and finish by comparing your solution with a partner.
| Section | Mode | What You'll Do |
|---|---|---|
| Understand | Individual | Compare two pseudocode solutions to the same problem. |
| Do | Individual | Write pseudocode for a new problem, from requirements through to a full solution. |
| Communicate | Partners | Exchange and compare your pseudocode with a partner. |
Submit: your Lab 2 Worksheet. There is no code this week, so no notebook is required.
Understand (Individual)
Setup: You are given two different pseudocode solutions to the same problem. Read both carefully before answering the questions below.
Problem: Movie Ticket Pricing
A group is buying movie tickets. Each ticket normally costs $12. If the group has 6 or more people, the whole group gets a 15% discount on the total.
Solution A
Ask the customer how many people are in the group.
Multiply the group size by $12 to get the total cost.
If the group size is 6 or more, take 15% off the total cost.
Show the total cost.
Solution B
Ask the customer how many people are in the group.
If the group size is 6 or more, the price per ticket is $12 with 15% off.
Otherwise, the price per ticket is just $12.
Multiply the group size by the price per ticket to get the total cost.
Show the total cost.
Solution C
Ask the customer how many people are in the group.
Multiply the group size by $12 to get the total cost.
If the group size is more than 6, take 15% off the total cost.
Show the total cost.
Answer the Reflection Questions on your Lab 2 Worksheet before moving to the Do section.
Do (Individual)
Setup: You will now solve a problem on your own using the same process. No code today — pseudocode only.
Problem: Pizza Order Total
A pizzeria charges $9 for a base pizza. Each topping adds $1.50. If the subtotal (pizza + toppings) is $20 or more, delivery is free. Otherwise, delivery costs $4.
Design a solution that takes in the number of toppings and outputs the final total the customer owes.
Work through the following steps and record your work on your Lab 2 Worksheet — you'll need it in Communicate.
- List requirements — What does the solution need to take in? What must it produce? What rules govern the calculation?
- Input-Process-Output model — Sketch what goes in, what happens to it, and what comes out.
- Break down the problem — What are the smaller steps or decisions involved?
- Write the pseudocode — Using the breakdown above, write your solution.
Answer the Reflection Questions on your worksheet before moving to Communicate.
Communicate (Partners)
Setup: Find someone else who has finished Do. Exchange and compare your pseudocode, then record your discussion and reflection answers on your Lab 2 Worksheet.