Go Back   Android Forums > Android Development > Application Development > App Inventor

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
 
LinkBack Thread Tools
Old June 7th, 2012, 03:51 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Jun 2012
Posts: 1
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Question Modestly asking for help with a Random Number Generator project

Alright so here is what I am trying to do. I want to click a button that will generate a number between 1 and 100 and then, I want the number to be displayed on the screen.

I also want to create conditional text depending on the number. For instance, if the random number generated is between 1 and 19, I want it to say a specific sentence after the number is displayed. If the number generated is between 20 and 40, I want a different sentence to be displayed.

I have been watching the MIT tutorials and trying to figure it out in the block editor to no avail. Any help would be greatly appreciated.

FreneticFerret is offline  
Last edited by FreneticFerret; June 7th, 2012 at 03:52 AM. Reason: typographical errors
Reply With Quote
sponsored links
Old July 3rd, 2012, 01:01 AM   #2 (permalink)
Junior Member
 
Join Date: Mar 2012
Location: Louisiana, USA
Posts: 33
 
Device(s): Asus Eee Transformer
Carrier: Not Provided

Thanks: 1
Thanked 4 Times in 3 Posts
Default

Create a label in the Screen Designer: Label1
In the blocks editor, drag out Screen1.Initialize block and put a [Label1.Text to ][random integer ](1,100) block inside.
When you run the app the number will display.
---
To have different messages display, you need to learn how to use the if and if-else blocks and how to form the blocks for the condition (true or false).

An example of the blocks needed for a number between 1 and 19 would be:

[if condition]([and][Label1.Text >= 1][Label1.Text <= 19])
[Label2.Text to ][ text "this is a small number."]
:
]
appinventor is offline  
Reply With Quote
Reply


Go Back   Android Forums > Android Development > Application Development > App Inventor
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 12:19 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.