0% found this document useful (0 votes)
25 views2 pages

Age Group Classifier App

Uploaded by

desirecutepol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Age Group Classifier App

Uploaded by

desirecutepol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Activity: Age Group Classifier App

Objective:
Create an app in MIT App Inventor where users input their age, and the app classifies them
into one of three age groups: "Child", "Teenager", or "Adult" using simple conditional blocks.

Step-by-Step Guide to Creating the "Age Group Classifier App"


1. Designing the User Interface
In the Designer section of MIT App Inventor, add the following components:
 TextBox (TextBox1): The user will input their age here.
o Hint: "Enter your age"

 Button (Button1): The user clicks this button to check which age group they belong to.
o Text: "Check Age Group"

 Label (Label1): This will display the result ("Child," "Teenager," or "Adult").
o Text: "Age group will be displayed here"

2. Adding Conditional Logic with Blocks


Switch to the Blocks section and set up the app’s logic using conditional blocks to classify the
user’s age.
Logic:
 If age < 13, classify as "Child."
 Else If age is between 13 and 19, classify as "Teenager."
 Else, classify as "Adult."

3. Setting Up the Conditional Blocks


Use the following blocks:
 Button1.Click: This event will trigger when the user presses the button.
 If-then-else block: To classify the age as "Child," "Teenager," or "Adult."

Block Setup:
1. Button1.Click Block:
o This block handles the event when the button is clicked.

2. If-Then-Else Block:
o Use the conditional block to classify the input from TextBox1.

o If age is less than 13, display "Child."

o If age is between 13 and 19, display "Teenager."

o If age is 20 or more, display "Adult."

Complete Block Structure:


plaintext
Copy code
When Button1.Click
if (TextBox1.Text < 13)
set Label1.Text to "Child"
else if (TextBox1.Text >= 13 and TextBox1.Text <= 19)
set Label1.Text to "Teenager"
else
set Label1.Text to "Adult"

4. Testing the App


Once the app is designed and the blocks are in place, you can test it on a mobile device. When
the app runs:
1. The user enters their age in TextBox1.
2. The user clicks the "Check Age Group" button.
3. The app evaluates the input and displays the appropriate age group in Label1.

Expected Output:
1. Input: 8 → Output: "Child"
2. Input: 15 → Output: "Teenager"
3. Input: 25 → Output: "Adult"

You might also like