In this project, we will create a BMI calculator using "if...then...else" control.
Mission 1: Simple conditional statements (Level 1)
Step 1: Identify the logic flow of the BMI calculator
BMI formula: BMI = kg/m2
Step 2: Set up the user interface
1. Set up the user interface for input first.
2. Add another screen to the app for the output of the result.
Step 3: Coding the app
1. In Screen1, when the Button1 is clicked, we should initiate Screen2. Finish the following block program in Screen1 with the use of the formula for calculating BMI.
2. In Screen2, when it is initiated, get the calculated result from the above block program and put it to the textbox "BMI_result".
3. Refer to the logical flow. You will need 3 "if-then" blocks for this app. The 1st one has been done for you as an example. Try to finish the 2nd and 3rd one.
Tips: use an "and" logic block for the 2nd condition.
Mission 2: Simplify the program - nested block (Level 2)
The above app can be simplified by using "nested-if" block (an "if-then" block inside another "if-then" block).
Refer to the following logic flow:
Click the small blue button on the "if-then" block for this mission. Can you finish the nested-if block by yourself?
Mission 3: Using variables (Level 3)
A variable stores a value that can be changed while the app is running.
1. Change the layout according to the following figure.
2. Initialize the variable "height" to store the data of height. At first, it should be 0.
3. The value of variable "height" should be increased based on the button pressed. For example, when the user presses "+1", the value of height should be increased by 1.
4. Can you apply the above skills and finish the event handler for the "+0.5", "+0.1", "+0.01" and "Reset" buttons?