CSCI N201: Programming Concepts
Department of Computer & Information Science / Indiana University-Purdue University Indianapolis

Miracle Lab 2: Loops

Goals

By the end of this lab you should:


Directions for Project A: Repetitive Structures

  1. You will need to use Miracle for this assignment. Click the following link to access Miracle:
    http://klingon.cs.iupui.edu/~aharris/MirJS.html

  2. 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.

  3. Below are images representing how the program might look (user took 3 guesses in this instance):








  4. 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".

  5. 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

  1. You will need to use Miracle for this assignment. Click the following link to access Miracle:
    http://klingon.cs.iupui.edu/~aharris/MirJS.html

  2. 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.

  3. 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







  4. 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".

  5. 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).