# Week 4 CheckPoint

Week 4 CheckPoint – Repetition and Decision Control Structures

In one of the week 3 discussion questions we discussed the algorithm that
would be required to make a peanut butter sandwich. In this CheckPoint you
will need to take that one step further and create a program design to make
peanut butter sandwiches.

Below you will find a partial program design; you need to complete it by adding
the pseudocode in the required areas. You need to add one repetition (loop)
control structure and one decision control structure to complete the program
design. The user will decide how many sandwiches are made; this is where the
loop will be used. The user will also decide if the sandwich includes jelly, and,
if it does, what flavor of jelly; to keep it simple we are only allowing grape or
strawberry jelly.

Analysis

Process:
1.
2.
3.
4.

Ask user how many sandwiches to make
If the user enters 0 for number of sandwiches the program should end
Ask user if they want jelly on their sandwich
If jelly is requested, ask user what flavor (grape or strawberry) of
jelly they would like
5. Make sandwiches

Input:

numberOfSandwiches
includeJelly
typeOfJelly

Output:
Sandwich

Design

Main Module

Declare numberOfSandwiches as integer
Declare includeJelly as string
Declare typeOfJelly as string
Declare continue as Boolean
Set continue to true

Do While continue = true
Call InputModule
EndDo

(integer)
(string; values Yes/No)
(string; values Grape/Strawberry)

End Main Module

InputModule

Display “How many sandwiches would you like to make? Enter 0 to end
program.”
Input numberOfSandwiches

If numberOfSandwiches = 0
Set continue = false
Else
Display “Do you want jelly on your sandwiches?”
Input includeJelly

If includeJelly = “Yes”
Display “What type of jelly; Grape or Strawberry?”
Input typeOfJelly
EndIf
While numbreOfSandwiches > 0
Subtract 1 from numberOfSandwiches
Call SandwichModule
EndWhile
EndIf

End InputModule

SandwichModule