CSCE 101: Introduction to Computer Concepts

Lab8–Loops!

Academic Honesty

  • The work you turn in is to be your work, not copied from someone else, from the web, or generated by a program.
  • Never allow anyone access to your files.
  • Never give anyone your password.
  • Never share your USB memory or email your files to anyone else.
  • Never give anyone a printed copy of your file or an electronic copy.
  • Never allow anyone to copy your work.

Purpose

We will be practicing for each and while loops. You will create six loops, really three pairs of loops. The first loop of each pair will be given to you and for the second loop you should be able to use your understanding of the first to do it.

  • Name your project: LoopsXY, where XY are your initials.

Design

You will be creating two screens, that will look as follows:

Screen1:

/ TextBox:
  • This will display the output when a button is clicked
  • Name it: Output
  • Properties:
  • Enabled: false (user can’t type here)
  • Height: 200px
  • Width: Fill Parent
  • Hint: Click a button
  • MultiLine: true
Buttons:
  • Display the buttons in a TableArrangement
  • Give the buttons appropriate names, e.g.
  • ChecklistButton
  • EmailsButton…

EmailScreen:

/ TextBox:
  • This will display the output when a button is clicked
  • Name it: EmailOutput
  • Properties:
  • Enabled: false (user can’t type here)
  • Height: 200px
  • Width: Fill Parent
  • Hint: Click a button
  • MultiLine: true
HorizontalArragement
  • Create a HorizontalArragement to hold the UsernameTextBox, and UsernameButton
Bottom Buttons
  • Create the Print Emails and Back button, and give them appropriate names

Checklist Button, Screen1

This button will loop through and display a list of items the user frequently forgets, e.g. cellphone, glasses…

Use the provided code for this button:

Note: “\n” creates new lines

Email Button

  • This button directs the user to the EmailScreen
  • Now go to the email screen to do the work

Print Emails Button

  • Create a global list which holds at least 3 usernames, e.g. joebloe (Not full email addresses)
  • When the Print Emails button is clicked, it will use a list for each loop, to loop through the usernames.
  • As it loops through the list, it will append “@email.sc.edu” to the end of each list item and display it.
  • Sample display:

Add Username Button

  • When the “Add Username” button is pushed, it should take the contents of the username textbox and add it to the list of usernames.
  • Then the next time the Print Emails button is clicked, the new name will also display as part of the list

Back Button

This button will take the user back to Screen1

Liftoff Button (Screen1)

This button will display the text:

3

2

1

Liftoff!

Provided Code:

Cheer Button

This button will display the cheer below: Note: You must use a loop

2

4

6

8

Who do we appreciate!

Notifier

In Screen1, add two Notifier Components. These Notifiers will be associated with the Factorial and Power buttons. Call them:

  • FactorialNotifier, and
  • PowerNotifier

Factorial Button

This button will display the factorial of a number.

e.g. 5! = 5*4*3*2*1 = 120

Provided Code

Power Button

This button will first ask the user for how many power’s of two they want.

e.g. if the user enters 5, they want: 25 = 2*2*2*2*2 = 32

You will use a Notifier, just like with the Factorial Button to ask the user what number they want as the Power, then you will display the result.

e.g. if the user enters 4, display 16

Submitting your files

  • Make sure you have tested your app, and that it works perfectly
  • Open “My Projects” in the upper right of the App Inventor webpage
  • Put a check next to the project you want to download (you can only download one at a time). Download the modified version of your app, if you have multiple copies.
  • Select Projects ->"Export selected project (.aia) to my computer"
  • The file will download so go, in Chrome, to the download location by clicking the arrow next to the file name at the bottom of the screen and selecting "Show in folder".
  • Move the ______.aia file to your X:\101Labs directory for grading.
  • Make sure that your file is named LoopsXY.aia, where XY are your initials, as this is the file we will be looking for when grading.

Grade Breakdown

Points / Functionality
5% / Checklist Button
30% / Email Button and screen
5% / Liftoff Button
25% / Cheer Button
5% / Factorial Button
30% / Power Button