Skip to main content

In Sketchware: How to create a calculator for any simple formula?

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 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.
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:

Comments

Popular posts from this blog

Create Music Player app in Sketchware

To create a Music Player app in sketchware, follow the steps given below. 1. Create a new project in Sketchware. 2. In VIEW area on main.xml, add a ListView  listview1  with height wrap_content, and weight 1. Add a SeekBar  seekbar1 , an ImageView  imageview1 , and three TextViews  textview1 ,  textview2 , and  textview3 , as shown in the image below. 3. Create a CustomView  mycustom.xml  and add a TextView  textview1 , and an ImageView  imageview1  in it. For listview1 select mycustom.xml as it's customView. 4. Add a MediaPlayer component  mp , a Shared Preferences component  sp:sp  and a Timer component  timer . 5. Create six More Blocks  MPcreate(pos), MPstart , and  MPpause  for the MediaPlayer and  searchFolders ,  getFileList in [filePath]  and  extra . 6. Add three number variables  n, r  and  songPosition , and five String variables  currentfile ...

Admob rewarded video Ads in Sketchware

To integrate Admob Rewarded Video Ads to a Sketchware project, follow the steps given below. Prerequisites An Android project (Sketchware project) Account in Admob Always place the test ad unit ID before placing your ad unit ID. App ID and ad unit ID can be obtained by registering the app on Admob. But for using test ads no registration is required. Do not click on your own Ads. 1. Create an android project in Sketchware. 2. Add the app to your Admob account. For your app, generate an ad unit ID for Rewarded Video Ads. 3. In Sketchware project, navigate to  Library Manager  and open Admob settings. i. Click on Add manually and add the ad unit ID generated on Admob website, or use test ad unit ID ca-app-pub-3940256099942544/5224354917. ii. If you are not using any banner or interstitial ad units, select the same ad unit ID for both banner and interstitial ads. iii. Add Test Device automatically shown by Sketchware. iv. Save it. v. Switch ON Admob and AppCompat and design. ...

Firebase auth in Sketchware for Login Activity

To create a login activity using Firebase Auth in Sketchware, follow the steps given below. This method uses Firebase authentication service for creating login. 1. In your Firebase account, go to Firebase authentication. 2. In Firebase authentication web set-up, go to SIGN-IN method, and enable Email/password and Anonymous. 3. Go to Project settings in your Firebase project and copy the Web API Key, Project ID, and App ID. 4. Paste the Project ID, App ID, and Web API Key in your project in Sketchware, in the Firebase settings. 5. On the  MainActivity  page add a File Shared preferences component  user:user  and an Intent  i . Also add a Timer  t  and a Firebase Auth  testlogin . 6. Create a new page  login.xml  with Activity called  LoginActivity . 7. In  onCreate  event of MainActivity use blocks as shown in image below. It identifies main page with  File user key page . It also checks if user is logged in to  F...