skip to content

Calculator

To create a calculator app using MIT App Inventor, follow these steps:

Step 1: Setup and Create Project

  1. Open MIT App Inventor:

  

  1. Create a new project:

    • Click on “Projects” and choose “Start new project”.
    • Name your project, for example, “CalculatorApp”.

 

 

 

Step 2: Design the User Interface

  1. Go to the Designer screen:

    • In the “Designer” tab, you will design the app’s user interface.
  2. Add Labels and TextBox:

    • Label: Drag and drop a label onto “Screen1”. Rename it to “lblDisplay” and leave the Text field empty.
    • TextBox: Drag and drop a TextBox. This will be for user input (no need to rename it).

 

Add Buttons:

  • Button: Drag and drop 10 buttons. Rename each button and change their Text properties to “0”, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9” respectively.
  • Add four more buttons and change their Text properties to “+”, “-“, “*”, “/”, and “=”.

 

 

 

 

 

 

 

OPEN block code.

 

  • Create Variables:

    • Create a variable named “input” and set it to an empty text.
    • Create another variable named “operator” and set it to an empty text.
    • Create a variable named “result” and set it to 0.

Set Blocks for Operator Buttons:

  • For example, for the “+” button

Step 4: Test and Fine-Tune the App