Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Calculator apps
Program math formulas with Small
Basic.
a challenge for classrooms around the world.
“The 'Hour of Code™' is a nationwide initiative by
Computer Science Education Week and Code.org
to introduce millions of s...
About Calculator Apps project
This is a customized snack course for teachers and students of elementary and secondary scho...
Download link for Small Basic:
www.smallbasic.com
Download .NET 4.6 to install Small Basic:
https://www.microsoft.com/en-u...
Installation tips for Teachers:
1. First download and Install .NET ver 4.6 and above setup file.
2. Before downloading and...
Name of Lesson: Algorithms
Subject: ICT
Instructor: Ashiedu Jude
Grade:
Students that can solve basic math of addition, su...
Algorithm
Humans work with algorithms everyday unconsciously. This is how we live and this is also how
things get done fro...
Logical Algorithms
We have several logical or conditional ways of creating algorithms by using IF, GOTO and ENDIF
and ELSI...
Algorithm example 1
An Algorithm is like a cookbook you can not eat the menu on paper after
shopping for items. The foodst...
Algorithm example 2
You understand only English Language and you are given an essay to read in Chinese;
you will need to a...
Algorithm and Math
The basic mathematical symbols/operators :
1. Addition (on keyboard “+”)
2. Subtraction (on keyboard “-...
Algorithm and math exercises.
If you had a job that pays you $1000 monthly to add two numbers each minute everyday. Would ...
Algorithm and math exercises contd.
Algorithm solution: (2 + 3 = 5). The plus and equal (+, =) signs are the only stable (...
Algorithm and math exercises contd.
By changing the mathematical sign we can write an algorithm to subtract or multiply or...
Algorithm for shapes
The algorithm for finding the area of a square:
The algorithm for finding the Perimeter of a square:
...
Congratulations
you completed your
lesson on Algorithms.
Name of Lesson : Small Basic Calculator apps
Subject: ICT
Instructor: Ashiedu Jude
Grade:
Students that can solve basic ma...
Soccer commands and
Small Basic Programming
Lets compare playing soccer (football) to Small Basic programming:
Soccer as a...
SOCCER COMMANDS/RULES
One big soccer rule is kicking the ball; we can call it the KickBall command (STATEMENT,
VERB(action...
Small Basic Calculator app
EDITOR and SOURCE CODE
All rules in soccer work only in the FIELD; similarly in Small Basic, we...
1. TextWindow.WriteLine() - Moves & displays text on a new line in app screen.
2. TextWindow.Write() - Leaves & displays t...
Small Basic Calculator app
(Statements, Properties, Operations)
Small Basic app screen command is TextWindow. Like the Kic...
TextWindow Properties and Operations
Our entire lesson is focused on making Calculator apps,
using 5 Small Basic commands....
IntelliSense & Comments
1. IntelliSense in Small basic provides suggestions on commands you try using
on your EDITOR via a...
Small Basic Math Symbols & Commands
1. Division: /
2. Multiplication: *
3. Addition: +
4. Subtraction: -
5. Square root: M...
Small basic math example 1
O u r f i r s t a l g o r i t h m e x e r c i s e w a s t o
c r e a t e a m a t h f o r m u l a...
Small basic math Comments example 1
O u r a p p i s u p a n d r u n n i n g a s s o o n a s
w e p r e s s t h e F 5 k e y ...
Coding branches
Making a branch code is like turning your program into a cross road; or when
you try adding a menu options...
Small Basic Branch or Conditional commands
C r e a t i n g b r a n c h c o m m a n d s i n o u r
a l g o r i t h m a p p w...
Small Basic Branch or Conditional Statements
T h e a p p w e c r e a t e d i n t h e p r e v i o u s
s l i d e w o u l d c...
Small basic Math Objects
M a t h o b j e c t s g i v e s u s t h e o p t i o n t o
c r e a t e m o r e f o r m u l a s f o...
You can start by creating Small Basic calculator apps from these math formulas.
Small basic codes example 3
O u r f i n a l e x a m p l e w i l l b e o n o u r
a l g o r i t h m t o f i n d t h e A R E ...
Debugging
Debugging your code is correcting errors
(bugs) you made in the source code editor
during typing or working with...
Code debugging exercises 1
1. Type the codes and do not copy directly into your Small Basic source code editor.
2. Read th...
Code debugging exercises 2
1. Type the codes and do not copy directly into your Small Basic source code editor.
2. Read th...
Remember to:
1. Always SAVE your source code after each update you make.
2. Use the PUBLISH button on the toolbar menu to ...
Congratulations
you can now use
Small Basic to
program Math formulas.
Let the games begin!
Upcoming SlideShare
Loading in …5
×

Small Basic Calculator Apps lesson

974 views

Published on

Complete starter lesson for the Small Basic Calculator Apps math challenge for classrooms, all over the world.

Published in: Education
  • Be the first to comment

  • Be the first to like this

Small Basic Calculator Apps lesson

  1. 1. Calculator apps Program math formulas with Small Basic. a challenge for classrooms around the world.
  2. 2. “The 'Hour of Code™' is a nationwide initiative by Computer Science Education Week and Code.org to introduce millions of students to one hour of computer science and computer programming.” Hour of Code™ www.smallbasic.com www.code.orgashiedujude.blogspot.com #sbcalculatorapps #smallbasic #hourofcode #globalgoals www.csedweek.org
  3. 3. About Calculator Apps project This is a customized snack course for teachers and students of elementary and secondary schools worldwide, as part of the sustainable development project for quality education via global goals; for those who are new to computer programming and would love to have a starter pack to inspire them. Also, teachers who find it difficult to introduce computer programming in their classrooms, especially to ages 8 and 15 students will find it helpful to use, as a Kickstarter into explaining the rudiments of coding to these categories of young children. Small Basic is the sample programming language throughout this course due to it’s simplicity. It would be very difficult to introduce majority of young students into computer programming no matter how easy it is, without first creating a background check on Algorithms and how our day to day living depends on them. At interval you will meet my sidekick on Small Basic, his name is Wazobi, a stick figure that will take you through the course via animated videos.
  4. 4. Download link for Small Basic: www.smallbasic.com Download .NET 4.6 to install Small Basic: https://www.microsoft.com/en-us/download/details.aspx?id=53344 Details about Calculator Apps project at: ashiedujude.blogspot.com Discussion forums on Facebook and Twitter: @edujetage
  5. 5. Installation tips for Teachers: 1. First download and Install .NET ver 4.6 and above setup file. 2. Before downloading and installing Small Basic setup file. If you have multiple computer systems to install both setup files: 1. Copy both files from the download folder into a new folder. 2. Rename the new folder and copy it into an external storage (Flash drive etc) 3. Switch on all computer you would need to install both setup files. 4. Copy and paste the setup folder containing files on each PC. 5. Then begin installation.
  6. 6. Name of Lesson: Algorithms Subject: ICT Instructor: Ashiedu Jude Grade: Students that can solve basic math of addition, subtraction, multiplication, division. Subject of Lesson: 1. Definition and uses of Algorithms in day to day activities. 2. Logical Algorithm 3. Algorithms in relation to mathematics. 4. Algorithms in relation math exercises. Pupils/students assignment: * List short details of your activities in the last one hour. * List short details of your activities in the last 24 hours * Write an algorithm to add up five numbers. * Write an algorithm to add up two numbers and divide them by a single number. * Lesson outline/Objective: • Learners can create simple algorithms from math formulas. • Learners can automate an algorithm with conditional events. Teacher’s notes: * * References(Books/web etc.): * * Resources: * Photos and video about algorithm. • A foot ball • Food menu and recipe on cards • Short essay in English language and a Foreign language . Minutes: 30-45 Overview/Purpose: To enable learners understand Algorithms and how we create them on daily basis.
  7. 7. Algorithm Humans work with algorithms everyday unconsciously. This is how we live and this is also how things get done from your to-do list to your shopping lists. The algorithm of an average student’s life is as simple as: This can be expanded into details by breaking down each step further into mini algorithms like a table of contents. An Algorithm is simply a list of processes to complete a specific task or event. Algorithms help us understand how to write codes for the computer. Step 1: Home Step 2: School Step 3: Home Step 1: Home Step 1.1 Brush(Teeth) Step 1.2 Bath Step 2: School Step 3: Home
  8. 8. Logical Algorithms We have several logical or conditional ways of creating algorithms by using IF, GOTO and ENDIF and ELSIF commands. These are also Small Basic commands. Lets change your normal student routine, to a situation that happens when you fall sick on a school day. You find that our normal TASKS will change when there is a new EVENT. Step 1: Home Step 2: IF sick Step 3: GOTO hospital Step 4: ELSEIF treated Step 5: GOTO School Step 6: ENDIF Home Step 1: Home Step 2: School Step 3: Home
  9. 9. Algorithm example 1 An Algorithm is like a cookbook you can not eat the menu on paper after shopping for items. The foodstuffs has to cooked according to the process in the menu. If your tummy was a computer, it wouldn’t know how to digest raw foods; the cookbook is the algorithm, the chef is the programmer, while cooking the foodstuffs is the programming language. When you eat raw food you can become sick or get nauseated, because your tummy might be rejecting the raw form of the food. A computer programming language will reject an algorithm, if it doesn’t understand the form the algorithm was typed.
  10. 10. Algorithm example 2 You understand only English Language and you are given an essay to read in Chinese; you will need to ask someone that understands Chinese and English languages to translate it for you. The person who translates would write an short note (algorithm) on the meaning of each Chinese word or sentences in English, before typing as the essay for you. Humans can only teach computers in special languages called programming languages or codes. Algorithms helps us understand how computers work and they are the best way to explain our commands to computers. Algorithms are written step-by-step and computer programming languages obey commands (codes) one step at a time.
  11. 11. Algorithm and Math The basic mathematical symbols/operators : 1. Addition (on keyboard “+”) 2. Subtraction (on keyboard “-”) 3. Division (on keyboard “/” 4. Multiplication (on keyboard “*”) In computer programming, humans are the teachers, while computers are the learners. Computers are blind, deaf, dumb, and they are still growing; your job as a programmer is to teach computers to see, hear, talk and solve problems faster, so you have more time to play. When writing an Algorithm for a computer code, you are going to use a mouse and keyboard, your algorithm will have similarities with keys on the keyboard. By teaching a computer to solve a problem, it will never forget it. This will give you time to focus on teaching the computer more algorithms.
  12. 12. Algorithm and math exercises. If you had a job that pays you $1000 monthly to add two numbers each minute everyday. Would it not be smart to let your computer do the math? This is a simple exercise in numeracy (2 + 3 = 5). We can use images to represent the numbers Now solve this: 1,000,000,000,000,000,000,000,000,000 + 2,000,000,000 = ? Both exercises are still the addition of two numbers but the second exercise will take you more time to figure out and pronounce. But it will take a computer the same time (less than 0.1 sec) to calculate both math exercises with an algorithm that can be changed into a Small Basic code.
  13. 13. Algorithm and math exercises contd. Algorithm solution: (2 + 3 = 5). The plus and equal (+, =) signs are the only stable (constants) items in the math exercise, the rest are unstable “2,3,5” (variables/changing). We need to create a formula to keep adding two numbers, and formulas are created using the ALPHABET, but NUMBERS are used to test if the formulas can calculate. With this algorithm we can use any computer programming language to write a code to add up two numbers, even if the numbers are in trillions. the formula now has to come before the answer, so we swop the Steps 3 to Step 4, to make the algorithm calculate properly. Step 1: The first number is 2, we can call it alphabet A Step 2: The second number is 3, we can call it X Step 3: The third number is the answer 5, we can call it Z Step 4: The formula looks like this (A+X=Z) Step 3: A+X = Z Step 4: Z = 16 Step 1: First alphabet A = 11 Step 2: Second alphabet X = 5
  14. 14. Algorithm and math exercises contd. By changing the mathematical sign we can write an algorithm to subtract or multiply or divide any two numbers; which looks like this: With just one algorithm we have four more algorithms that can be made into simple calculator apps, using Small Basic programming language. An algorithm also helps us control how an app should work. Robots, the internet, software, apps all work with specific algorithms. We will learn how to convert our algorithms into Small Basic codes for the computer to learn how to make use of it. Step 1: The first number is 2, we can call it alphabet A Step 2: The second number is 3, we can call it X Step 3: The third number is the answer 5, we can call it Z Step 4: The formula looks like this (A+X=Z) or (A-X=Z) or (A/X=Z) or (A*X=Z)
  15. 15. Algorithm for shapes The algorithm for finding the area of a square: The algorithm for finding the Perimeter of a square: Remember all sides of a square are equal, so you do not need to have different length, width or height. For other shapes like the rectangle we will need to add more steps to our algorithm to get numbers for width or base height. Step 1: Length of one side is G Step 2: Area = G*G Step 1: Length of one side is K Step 2: Perimeter = 4K
  16. 16. Congratulations you completed your lesson on Algorithms.
  17. 17. Name of Lesson : Small Basic Calculator apps Subject: ICT Instructor: Ashiedu Jude Grade: Students that can solve basic maths of addition, subtraction, multiplication, division. Subject of Lesson: 1. General introduction to 3 STATEMENTS, PROPERTIES and OPERATIONS relevant for the lesson in Small Basic 2. Three major Small Basic STATEMENTS, PROPERTIES and OPERATIONS to solve most Math Problems 3. Automating Small Basic calculator apps with Conditional, Loop Statements. 4. Debugging simple codes Students assignment: * Create a Small Basic app to multiply 5 numbers. * Create a Small Basic app to calculate with this formula (K+y)5 * Create a Small Basic app to calculate with this formula (a+b)(m+n) * Create a Small Basic app to calculate the area of a Triangle * Debug the Codes at the end of the slide lesson. Lesson outline/Objective: • Learners can use 3 major Small Basic commands solving simple math problems with the idea of Soccer rules. • Learners can create simple Calculator apps using Small Basic with the idea gained from writing Algorithms. • Learners can automate their Calculator app with conditional statements (If, Goto, Endif, Elseif etc) Teacher’s notes: * Teachers can create more exercises for their students based on current level in numeracy. References(Books/web etc.): * Small Basic PowerPoint tutorials at smallbasic.com * Resources: * Relevant football match photos, videos, sound files. * A physical Football * A computer with Small Basic installed * Printed list of Math formulas for shapes. Minutes: 70 Overview/Purpose: To enable learners understand Small Basic STATEMENTS, PROPERTIES & OPERATIONS for solving simple Math problems or what we can call Mini calculators, with previous idea
  18. 18. Soccer commands and Small Basic Programming Lets compare playing soccer (football) to Small Basic programming: Soccer as a sport is made of some rules which makes us call it a game. Other sports like hockey, basketball, polo, NFL all have their special rules that makes playing their games special. You can not apply soccer rules to hockey, neither can you apply basketball rules to NFL. Computer programming languages are software with special commands for creating apps. They are like different sports with their special rules. Small Basic has it’s own unique commands that helps you create apps.
  19. 19. SOCCER COMMANDS/RULES One big soccer rule is kicking the ball; we can call it the KickBall command (STATEMENT, VERB(action word), Rule), which is done with the LEGS only, we do not kick the ball with our hands. It is wrong or an error to do that. We must KickBall to Pass, Dribble or take a Shot. We can make up a Soccer Command Plan: Lets put these soccer commands into groups i.e 1. KickBall (STATEMENT group); 2. Pass, Dribble, Shot (PROPERTY group). Statement and property are separated by a DOT; 3. Actions you put inside the bracket (OPERATIONS group) KickBall KickBall.Pass (a team mate to read your action) KickBall.Dribble (trick opponent with the ball) KickBall.Shot (towards a distant position) Automatic ball actions includes (this will lead us to conditional commands: 1. Ball Bounces. 2. Ball spinning on the floor. 3. Ball going out of the field.
  20. 20. Small Basic Calculator app EDITOR and SOURCE CODE All rules in soccer work only in the FIELD; similarly in Small Basic, we have an EDITOR that allows us to type in all commands that Small Basic must obey, in order to create our Calculator apps, we call these step-by-step commands SOURCE CODES. The Small Basic EDITOR looks like the photo below: F5 or RUN tells Small Basic to create an app from all commands (SOURCE CODES) we typed in the Editor LINES numbers gives us the number of code line typed, when we press the F5 key or RUN button. Source Code Editor for typing codes
  21. 21. 1. TextWindow.WriteLine() - Moves & displays text on a new line in app screen. 2. TextWindow.Write() - Leaves & displays text on same line in app screen. 3. TextWindow.Read() - Allows letters to be typed in app screen. 4. TextWindow.ReadNumber() - Allows numbers to be typed in app screen. 5. Math.Power(number, powernumber) - i.e. 73 is Math.Power(7,3) 6. Math.Pi or Math.Cos() or Math.Tan() or Math.Sin() i.e. Math.Cos(30) 7. Math.SquareRoot() - To get the square root of a number. 8. GOTO, THEN - Command for branching one code to another. 9. IF, ELSEIF, ENDIF. - To create a branch of events when coding. 10. Inverted comma ‘ - Allows you comment on a line of code 11. Quote marks “” - Works with .Write() or .WriteLine to display text in quote marks on app screen. ie. 12. Variables - Numbers or letters you create that are not in Small Basic; commands i.e. total = sum1 + sum2 Summary of important Small Basic commands for the Calculator Apps lesson
  22. 22. Small Basic Calculator app (Statements, Properties, Operations) Small Basic app screen command is TextWindow. Like the KickBall STATEMENT works with other commands like (PASS, DRIBBLE or SHOT) separated by a DOT in our Soccer Command Plan. All calculators have a small screen that displays RESULTS. The TextWindow STATEMENT command tells Small Basic to display a small black app screen after the next command, when we press the F5 button on the keyboard or click RUN on the monitor. The small black screen shows that our calculator apps can display any result we are going to program on the SOURCE CODE editor. Small black app screen appears after pressing F5/RUN button Source Code
  23. 23. TextWindow Properties and Operations Our entire lesson is focused on making Calculator apps, using 5 Small Basic commands. Small basic understands when you use the commands in the combination given below: i.e. TextWindow.Write (“Calculator Apps”) Displays the comment in the quote on the small black app screen after pressing F5/RUN. Using WriteLine instead of Write put your cursor on the next line in the small black app screen. TextWindow.ReadNumber() Displays a cursor for you to type in numbers only on the small black app screen after pressing F5 Take note of the DOT in-between the STATEMENT and PROPERTIES TextWindow Write WriteLine Read ReadNumber Clear STATEMENT
  24. 24. IntelliSense & Comments 1. IntelliSense in Small basic provides suggestions on commands you try using on your EDITOR via a small box. It also provide you with the proper spelling and usage of a command you are not too sure of. 2. Comments help you keep a note on each line of command you typed. As a young computer programmer, it is easy to forget the use of a code your typed on the Editor; a comment uses an “Inverted comma”, which tells Small Basic to ignore any command after the inverted comma. i.e ‘this is to test comments. comment Code Only code in QUOTE was displayed
  25. 25. Small Basic Math Symbols & Commands 1. Division: / 2. Multiplication: * 3. Addition: + 4. Subtraction: - 5. Square root: Math.SquareRoot(number) 6. Power: Math.Power(number, x) 7. Equal: = 8. Greater than: > 9. Less than: <
  26. 26. Small basic math example 1 O u r f i r s t a l g o r i t h m e x e r c i s e w a s t o c r e a t e a m a t h f o r m u l a t o a d d u p t w o n u m b e r s . W e c a n n o w w r i t e S m a l l B a s i c c o d e s f o r o u r a l g o r i t h m i n t o : T h e S m a l l B a s i c c o d e s s e e m t o b e d o u b l e d f o r e a c h l i n e o f a l g o r i t h m , b e c a u s e w e n e e d e d t o c h a n g e i t f r o m h u m a n l a n g u a g e t o a c o m p u t e r l a n g u a g e . A n d a l s o h e l p u s r e a d w h a t t h e a p p w a n t s w h e n w e p r e s s F 5 o r R U N b u t t o n . TextWindow.Write("Type the first number we call A:") firstnumber = TextWindow.ReadNumber() TextWindow.Write("Type the second number we call X:") secondnumber = TextWindow.ReadNumber() addingnumbers = firstnumber + secondnumber TextWindow.Writeline(addingnumbers) Step 1: The first number is 2, we can call it alphabet A Step 4: The formula looks like this (A+X=Z) Step 2: The second number is 3, we can call it X Step 3: The third number is the answer 5, we can call it Z App screens Source code editor
  27. 27. Small basic math Comments example 1 O u r a p p i s u p a n d r u n n i n g a s s o o n a s w e p r e s s t h e F 5 k e y o n t h e k e y b o a r d o r R U N b u t t o n o n s c r e e n . A d d i n g c o m m e n t s a t t h e b e g i n n i n g a n d i n - b e t w e e n t h e p r o g r a m m a k e s i t e a s y t o r e a d a n d e x p l a i n t o y o u r t e a c h e r w h e n y o u r r u n t h e a p p u s i n g F 5 k e y . C o m m e n t s y o u w a n t d i s p l a y e d i n t h e a p p s c r e e n a r e a l w a y s i n Q U O T E m a r k s ( “ c o m m e n t s ” ) . W h i l e C o m m e n t s t o e x p l a i n w h a t e a c h c o d e l i n e d o e s a r e p l a c e d a f t e r a n i n v e r t e d c o m m a ( ‘ ) . A n d t h e y d o n o t a p p e a r i n t h e a p p s c r e e n a f t e r p r e s s i n g F 5 o r R U N . TextWindow.WriteLine("THIS APP ADDS ANY TWO NUMBERS") 'to display text in quote marks TextWindow.Write("Type the first number we call A:") ‘to display text in quote marks firstnumber = TextWindow.ReadNumber() ' app ask for 1st number TextWindow.Write("Type the second number we call X:") 'to display text in quote marks secondnumber = TextWindow.ReadNumber() 'app ask for 2nd number addingnumbers = firstnumber + secondnumber 'app calculates by adding numbers TextWindow.Write("ADDING THE TWO NUMBERS GIVES:") 'to display text in quote marks TextWindow.Writeline(addingnumbers) 'app display answer App screen Source code editor
  28. 28. Coding branches Making a branch code is like turning your program into a cross road; or when you try adding a menu options into your app. You will notice such events on a phone call voice menu i.e. For English press 1 For Spanish press 2 GOTO, THEN, IF, ELSEIF & ENDIF are branch commands in Small Basic. IF English THEN GOTO 1 ELSEIF Spanish THEN GOTO 2 ELSEIF Yoruba THEN GOTO 3 ELSEIF Hausa THEN GOTO 4 ENDIF Press 1 for English. Press 2 for Hindi. Press 3 for Yoruba. Press 4 for Chinese. 1 2 3 4 For each branch you will have to create other events when coding. These events represents each branch, which are options your app gives the user.
  29. 29. Small Basic Branch or Conditional commands C r e a t i n g b r a n c h c o m m a n d s i n o u r a l g o r i t h m a p p w i l l m a k e t h e m a t h a p p a u t o m a t i c w i t h I F , G O T O , T H E N a n d E N D I F . Start: TextWindow.WriteLine("THIS APP ADDS ANY TWO NUMBERS") 'to display text in quote marks TextWindow.Write("Type the first number we call A:") ‘to display text in quote marks firstnumber = TextWindow.ReadNumber() ' app ask for 1st number TextWindow.Write("Type the second number we call X:") 'to display text in quote marks secondnumber = TextWindow.ReadNumber() 'app ask for 2nd number addingnumbers = firstnumber + secondnumber 'app calculates by adding numbers TextWindow.Write("ADDING THE TWO NUMBERS GIVES:") 'to display text in quote marks TextWindow.Writeline(addingnumbers) 'app display answer TextWindow.WriteLine("Type 1 to Continue Calculation") ‘to display text in quote marks TextWindow.WriteLine("Type ENTER key to Stop Calculation") ‘to display text in quote marks start = 1 ‘to repeat addition when 1 is pressed If TextWindow.ReadNumber() = 1 then ‘app waits for you to type 1 Goto start ‘app restarts addition pressing 1 EndIf ‘logic command to END the IF command Step 1: The first number is 2, we can call it alphabet A Step 4: The formula looks like this (A+X=Z) Step 2: The second number is 3, we can call it X Step 3: The third number is the answer 5, we can call it Z Step 5: Ask to start by pressing “1” or ENTER key Step 7: GOTO Step 1 Step 8: ENDIF app when ENTER key is pressed Step 6: IF “1” is pressed THEN Source code editor
  30. 30. Small Basic Branch or Conditional Statements T h e a p p w e c r e a t e d i n t h e p r e v i o u s s l i d e w o u l d c l o s e a f t e r a d d i n g a n y t w o n u m b e r s . I f y o u r j o b w a s t o a d d s e v e r a l o t h e r n u m b e r s t h r o u g h o u t t h e d a y ; i t w o u l d b e s l o w , i f y o u h a v e t o p r e s s F 5 o r R U N b u t t o n e a c h t i m e y o u n e e d t o r e p e a t t h e a d d i t i o n p r o c e s s . Y o u c a n m a k e y o u r m a t h a p p k e e p r u n n i n g t i l l y o u w a n t i t t o s t o p c a l c u l a t i n g b y a d d i n g a b r a n c h c o m m a n d t o y o u r a l g o r i t h m a n d s o u r c e c o d e l i k e I F , E N D I F , G O T O , E L S E I F , a n d T H E N c o m m a n d s . Start: TextWindow.WriteLine("THIS APP ADDS ANY TWO NUMBERS") 'to display text in quote marks TextWindow.Write("Type the first number we call A:") ‘to display text in quote marks firstnumber = TextWindow.ReadNumber() ' app ask for 1st number TextWindow.Write("Type the second number we call X:") 'to display text in quote marks secondnumber = TextWindow.ReadNumber() 'app ask for 2nd number addingnumbers = firstnumber + secondnumber 'app calculates by adding numbers TextWindow.Write("ADDING THE TWO NUMBERS GIVES:") 'to display text in quote marks TextWindow.Writeline(addingnumbers) 'app display answer TextWindow.WriteLine("Type 1 to Continue Calculation") ‘to display text in quote marks TextWindow.WriteLine("Type ENTER key to Stop Calculation") ‘to display text in quote marks start = 1 ‘to repeat addition when 1 is pressed If TextWindow.ReadNumber() = 1 then ‘app waits for you to type 1 Goto start ‘app restarts addition pressing 1 EndIf ‘logic command to END the IF command App screen Source code editor
  31. 31. Small basic Math Objects M a t h o b j e c t s g i v e s u s t h e o p t i o n t o c r e a t e m o r e f o r m u l a s f o r o u r c a l c u l a t o r a p p s . W e a r e u s i n g t h e f o r m u l a t o f i n d t h e n u m b e r s t h a t a r e r a i s e d t o a n y P o w e r . i . e 𝟓 𝟐 , 𝟕 𝟒 , 𝟐 𝟎 𝟗 R e m e m b e r t o a l w a y s u s e t h e T e x t W i n d o w . W r i t e ( ) t o d i s p l a y M a t h . P o w e r ( n u m b e r , p o w e r ) o n A P P s c r e e n TextWindow.Write("Type a number to know the square:") ‘displays text square = TextWindow.ReadNumber() ‘app ask for number TextWindow.Write("The square of the number:") ‘displays text in quote TextWindow.Writeline(Math.Power(square,2)) ‘displays the power of 2 • Cos • Tan • Sin • SquareRoot • Power • Pi Math. App screens Source code editor
  32. 32. You can start by creating Small Basic calculator apps from these math formulas.
  33. 33. Small basic codes example 3 O u r f i n a l e x a m p l e w i l l b e o n o u r a l g o r i t h m t o f i n d t h e A R E A a n d P E R I M E T E R o f a S q u a r e . TextWindow.WriteLine("App to calculate AREA & PERIMETER of a square") TextWindow.Write("Type the value for any side:") ‘app displays texts gsides = TextWindow.ReadNumber() ‘app wants length typed TextWindow.Write("The AREA of the square is:") ‘app display text TextWindow.WriteLine(Math.Power(gsides,2)) ‘app calculates & display area TextWindow.Write("The PERIMETER of the SQUARE is:") ‘app displays text TextWindow.Writeline(gsides*4) ‘app calculates & display perimeter Step 1: Length of one side is G Step 2: Area = 𝑮 𝟐 Step 1: Length of one side is G Step 2: Perimeter = 4 * G App screens Source code editor
  34. 34. Debugging Debugging your code is correcting errors (bugs) you made in the source code editor during typing or working with Small Basic codes. Making errors or mistakes in your source code stops your code from becoming a app when your press F5 or RUN button. Small Basic EDITOR will show you the LINE number(s) where error(s) where found, with an error message on each line. You can also debug a code by reading the COMMENTS section to know what it was meant to do; then you can rewrite the algorithm. The LINE number where an error was found. Error messages to read Source code editor
  35. 35. Code debugging exercises 1 1. Type the codes and do not copy directly into your Small Basic source code editor. 2. Read the comments to find out what each line of code is meant to calculate. 3. Retype the correct commands, formulas or algorithm. 4. Use F5 or RUN button to test and see if the source can now create an app screen TextWindow.Write("Type a number to know the 2nd power:") ‘displays text square = TextWindow.ReadNumber() app ask for number TextWindow.Write("The square of the number:") ‘displays text in quote TextWindow.Writeline(Math.Power(square,2)) displays the the 2nd power TextWindow.Write("Type a number to know the fourth power:") ‘displays text fourthpower = TextWindow.ReadNumber() ‘to type a number TextWindow.Write("The fourth power of the number:") ‘displays text in quote TextWindow.Writeline(Math.Power(square,1)) ‘displays fourth power of number 1 2
  36. 36. Code debugging exercises 2 1. Type the codes and do not copy directly into your Small Basic source code editor. 2. Read the comments to find out what the code is meant to calculate. 3. Retype the correct commands, formulas or algorithm. 4. Use F5 or RUN button to test and see if the source can now create an app screen TextWindow.WriteLine("A app to add two numbers") ‘to display text in quote Write("Type the first number we call A:") ‘to display text in quote firstnumber = TextWindow.ReadNumber() ‘app asks for number TextWindow.Write("Type the second number we call X:") ‘to display text in quote secondnumber = TextWindow.ReadNumber() addingnumbers = firstnumber + secondnumber TextWindow.Write("Addition of the two numbers:") ‘to display text in quote TextWindow.Writeline(addingnumbers) ‘to display text in quote TextWindow.WriteLine("A program to multiply two numbers") ‘to display text firstnumber = TextWindow.ReadNumber() ‘to get 1st number secondnumber = TextWindow.ReadNumber() ‘to get 2nd number multiplynum = firstnumber + secondnumber ‘to multiply 1st & 2nd number TextWindow.WriteLine(multiplynum) ‘to display the answer 1 2
  37. 37. Remember to: 1. Always SAVE your source code after each update you make. 2. Use the PUBLISH button on the toolbar menu to share your source codes. 3. Use the above samples as an example to add details to code before publishing (Update button). 4. Test your calculator app(s) to see how well it solves some math exercises in your math text book. Reminder… 2 Small Basic Calculator Apps challenge. “The purpose of your program” . #sbcalculatorapps adding 3 numbers formula by “YOURNAME” Math (Algorithms) Use the samples when publishing your source code. Small Basic Calculator Apps challenge. “The purpose of your program”. #sbcalculatorapps YOUR NAME e.g Gates B. NAME of your Teacher e.g Mrs Barnes class NAME of your school e.g City High State & Country e.g Lagos, Nigeria 1
  38. 38. Congratulations you can now use Small Basic to program Math formulas.
  39. 39. Let the games begin!

×