Petit Tutorials - Calculator

Hello! I'm CKlidify, and in this tutorial I will teach you how to create your first program! A calculator!

Knowlage Required
You'll need to know what PRINT and INPUT is.

You'll need to know GOTO and IF.

OPTIONAL: You'll need to know BEEP and COLOR

Look at my previous tutorials for these!

Creating the Program
Do you own a calculator? No...

'''Do you have $7? 'Yes! I should buy one then!''

NO! YOU SHOULDN'T! Wh-why not?

'''Because you can acheive much more with $7 with PETIT COMPUTER! 'What's that!?''

'''It's where you can create your own programs that you can ply on your DSi or 3DS system! '...''

'''You can make your own calculator... '*GASP*''

Okay, in all seriousness, let's begin. You want to start off by clearing the screen with "CLS", then set the color to 0 and add a cool logo. CLS COLOR 0 PRINT "CALCULATOR by me" Okay, now let's create a "waypoint" named loop, change the color to 13 (RED) and ask for an input for one number, and another input, for the second number. We'll mak it beep inbetween each input and... @LOOP COLOR 13 INPUT "You got a number";NO1 BEEP 3 INPUT "Got another";NO2 BEEP 3 Now, let's add the operation selection! create a new "waypoint" named ope, change the color to 10 and ask for an input for the operation. Then make a couple of if statements to go to other waypoints to create and viola! @OPE COLOR 10 INPUT "What operaton";OP$ IF OP$=="+" THEN GOTO @ADD IF OP$=="-" THEN GOTO @SUB IF OP$=="X" THEN GOTO @MUL IF OP$=="*" THEN GOTO @MUL IF OP$=="/" THEN GOTO @DIV

Now, let's create something that prevents them from inputing something other than those characters! Create a new "waypoint" named incorr and make it print OP$ is not a proper operation then go to ope. @INCORR PRINT OP$ + " is not a proper operation" GOTO @OPE Okay, now let's create the @ADD, @SUB, @MUL and @DIV. I'm only going to show you how to do @ADD, because it's the same formula for each one. Plus, I'm not trying to baby you because you should already know all these commands from watching my previous tutorials! You want to add a new "waypoint" named add, then set the color to 11 and create a var named sum and set it to no1 + no2. then print the sum is SUM. then goto @END @ADD COLOR 11 SUM=NO1+NO2 PRINT "The sum is ";SUM;" GOTO @END Now, we're going to create @END. Create a new "waypoint" named end. Then set the color to 0 and make a beep and go to @LOOP @END COLOR 0 BEEP 6 GOTO @LOOP Now, we could have just added this to each operation, but this saved time and lines of code. If it's going to be in all lines of code, why not just point them all to one central code?

''Ohh, I get it now! 'GOOD! YOU BETTER!'''

''But how do I create a number guesser? ''Next time...