Topics 2:
Properties and events of a component. Simple calculation and assignment
statements. Key points:
Build in Blocks
Practical 2A: Calculating Body and Mass Index (BMI) Program requirements: 1. Input your weight (in kg) and height (in m) in 2 Textbox. 2. When a Button was clicked. Calculate the BMI ratio with the formula: BMI = weight / (Height x Height) 3. Show the BMI value in a Label.
Instructions: A. Login the web based platform http://appinventor.mit.edu and create a project called BMIcalculation. B. Design the layout of your apps in App Designer. Ø You have to use at least 2 textboxs, 2 horizontalarrangement, 2 labels and 1 button. Ø Rename the ‘Textbox1’ and ‘Textbox2’ as ‘Textboxheight’ and ‘Textboxweight’. Ø Rename ‘Button1’ as ‘ButtonCalculate’ Ø Rename ‘Label1’ and 'Label2' as ‘LabelR1’ and 'LabelR2' Ø Change the properties of the component as follows:
C. Build your program with Block Builder. Drag the following blocks and build your program. D. Test your apps with emulator Ø Start the emulator and unlock the emulated phone. Ø Click ‘connect to device’ E. Package the phone apps for submission Ø Click ‘Package for phone’ and ‘Downloads to this computer’ Ø Submit the Downloaded file in eclass. Video 1: Design your Layout Video 2: Programming using Block Editor Solution of the apps: Extension activities 1. The normal BMI range depends on age. For adult, 18.5 – 25 is normal. 2. Using the if..then..else control structure, change the label.color or label.text according to the values calculated. You can add a label for this functions. 3. You can also displayed different image according to the BMI value. Suggested answer of extension activities |
Android Programming > AppInventor >