Miracle Lab 2: Loops
Goals
By the end of this lab you should:
- Understand how looping structures work in programming
- Understand how to program while loops to repeat actions until a given condition
is met
- Understand how counting loops work in programming
- Understand how to program for loops to repeat actions until a maxium number
is reached
- Understand how to combine for loops with other structures to add interest
to a program
Directions for Project A: Repetitive Structures
- You will need to use Miracle for this assignment. Click the following link
to access Miracle:
http://klingon.cs.iupui.edu/~aharris/MirJS.html
- Open the Miracle link above. After Miracle opens, create a program that
uses a while structure to check the user's "password". Ask the user
"What is the secrect password?". If the user answers correctly to password
that you define, then give the user a congratulations message. If the user
answers anything other than the password you specify, tell the user they got
the password wrong and prompt them for it again. Keep prompting for the correct
password until the user gets the correct password. Then, give the user a congratulatory
message. Store both the user's guess and the password in separate variables.
The program should react the same if the user enters the password in lowercase,
UPPERCASE or MixedCase.
- Below are images representing how the program might look (user took 3 guesses
in this instance):
- Open Notepad (usually found in Start/Programs/Acccesories). Switch to Miracle.
From Miracle's "Administrative Tasks" menu, select "View Source."
A new browser window should appear. In the new browser window, select "Select
All" from the "Edit" Menu. Now, click the "Edit"
menu again and select "Copy." Paste your copy into your Notepad
file. Save your file as "LoopsLabA.txt".
- Submit your lab via Oncourse using the Oncourse
Drop Box for this lab (if you need help using the Oncourse Drop Box, click
here for an FAQ).
Directions for Project B: Counting Loops
- You will need to use Miracle for this assignment. Click the following link
to access Miracle:
http://klingon.cs.iupui.edu/~aharris/MirJS.html
- Open the Miracle link above. After Miracle opens, create a program that
uses a while structure to check the user's "password". Ask the user
"What is the secrect password?". If the user answers correctly to password
that you define, then give the user a congratulations message that tells them
how many tries it took them and end the program. If the user answers anything
other than the password you specify, tell the user they got the password wrong
and prompt them for it again, indicating to them the number of tries they
have left (maximum of three). Keep prompting for the correct password until
the user gets the correct password OR the user has given the password three
tries. Once the user has exhausted three tries, tell the user they are out
of tries. See the scenarios below for sample screenshots.
- Sample screenshots:
Scenario I - User Gets the Password in Less Than 3 Tries


Scenario II - User Fails to Get the Password in Less Than 3 Tries



- Open Notepad (usually found in Start/Programs/Acccesories). Switch to Miracle.
From Miracle's "Administrative Tasks" menu, select "View Source."
A new browser window should appear. In the new browser window, select "Select
All" from the "Edit" Menu. Now, click the "Edit"
menu again and select "Copy." Paste your copy into your Notepad
file. Save your file as "LoopsLabB.txt".
- Submit your lab via Oncourse using the Oncourse
Drop Box for this lab (if you need help using the Oncourse Drop Box, click
here for an FAQ).