In Sketchware: How to create a calculator for any simple formula?
Create a simple formula calculator Android app in Sketchware
Here is a tutorial to calculate using any simple formula, for users of Sketchware Android app.
I'll take the example of calculating volume of a cone.Formula is: Vcone = 1/3 × pi × r2 × h
Step 1
Download Sketchware
Step 2
Go to my projects and start a new project.
Fill details in Project Settings:-
Package name: com.cone
Project name: conevolume
App name: Cone Volume
App icon:
App version: 1.0
Step 2
Go to my projects and start a new project.
Fill details in Project Settings:-
Package name: com.cone
Project name: conevolume
App name: Cone Volume
App icon:
App version: 1.0
Step 3
Create View of your app. It is saved as main.xml. The process is simple. In the view field drag and drop 'linear', 'textview', 'button' and 'edittext' to places where you want them to appear.
In my project I have inserted 5 'linear', 4 'textview', 3 'edittext' and 2 'button'.
Edit the 'textview' fields to write details. Modify text of 'button' to write calculate, Reset, etc. Change background color of 'linear'. Modify Edittext to remove 'hint', and change 'input type' to 'number decimal'. I have modified Edittext1 and Edittext2 to take input of radius and height of cone, and Edittext3 is for volume output.
Step 4
After your view is set, click on 'Logic'.
You will find a screen as in picture below.
Click on onCreate and drag and drop 'set Enable' view into the field. Now choose 'Edittext3' and make setEnable 'false'
Step 5
Now go to 'Button 1 onClick'. Add three new 'variables'. I have added 'r', 'h' and 'vol'. Drag if - else control into field. Now add: if not length of Edittext1 and Edittext2 is > 0, show message ..., else... The picture below shows how to do it.
Now within 'else' field, set Variable 'r' to, toNumber Edittext1, and so on for all input fields. Set output variable 'vol' to your formula pi * r^2 * h / 3. Then set Edittext3 to your output variable 'vol'. It is shown in the picture below.
For any queries please write below.
In my project I have inserted 5 'linear', 4 'textview', 3 'edittext' and 2 'button'.
Edit the 'textview' fields to write details. Modify text of 'button' to write calculate, Reset, etc. Change background color of 'linear'. Modify Edittext to remove 'hint', and change 'input type' to 'number decimal'. I have modified Edittext1 and Edittext2 to take input of radius and height of cone, and Edittext3 is for volume output.
Step 4
After your view is set, click on 'Logic'.
You will find a screen as in picture below.
Click on onCreate and drag and drop 'set Enable' view into the field. Now choose 'Edittext3' and make setEnable 'false'
Step 5
Now go to 'Button 1 onClick'. Add three new 'variables'. I have added 'r', 'h' and 'vol'. Drag if - else control into field. Now add: if not length of Edittext1 and Edittext2 is > 0, show message ..., else... The picture below shows how to do it.
Now within 'else' field, set Variable 'r' to, toNumber Edittext1, and so on for all input fields. Set output variable 'vol' to your formula pi * r^2 * h / 3. Then set Edittext3 to your output variable 'vol'. It is shown in the picture below.
Step 6
Go to 'Button2 onClick', which is reset button and use 'settext' view for all three 'Edittext' to set them to empty.
Step 7
Now Compile and run the App. Your app is ready.
You can send the apk to your Email account to get the apk file. Or you can save it to your mobile directly using 'ES File explorer' app.
This video below is a tutorial on how to make an app for simple calculations:
Here is a video of a temperature converter created in Sketchware:
For any queries please write below.