# small basic

• ### Question

• hey guys i need alot of help writing a program for SB and could someone dumb it down for me

Design a software program that calculates the addition, subtraction, multiplication and division of two numbers. The user should access the calculator program by entering a password. If the user does not enter the correct password on the third try then the program should close.

When the user has the correct password, the program must prompt the user to enter two numbers and select a mathematical operation to process the entered numbers. The program should process the calculation and clearly display the final result.

Monday, May 4, 2020 12:29 PM

• You could break it down this way.

1. Create a Calculator that does what you need it to do.

2. Create a code for a password.

3. Integrate the password into the calculator program.

Following these three steps would help you to ease the path of program creation.

Friday, May 8, 2020 9:29 AM

### All replies

• Is this a school assignment?

We don't supply complete programs, but we can help you with problems you encounter during the development of your program. Start with a simple program: only the calculator without the password checking.. And try to make a program for checking the password. When both are working, combine them into one program./

Jan [ WhTurner ] The Netherlands

Monday, May 4, 2020 1:07 PM
• As a starter a simple calculator

```TextWindow.Write("Enter the first number:  ")
TextWindow.Write("Enter the second number: ")
TextWindow.WriteLine("Which calculation: 1=add  2=subtract  3=multiply  4=divide")
If calc=1 Then
ans=numb1+numb1
ElseIf calc=2 then
ans=numb1-numb2
ElseIf calc=3 then
ans=numb1*numb2
ElseIf calc=4 Then
ans=numb1/numb2
Else
TextWindow.WriteLine("This number is not allowed")
TextWindow.Pause()
Program.End()
EndIf
TextWindow.WriteLine("The result is "+ans)```

Jan [ WhTurner ] The Netherlands

Monday, May 4, 2020 5:34 PM
• Hey Jan,

The same program but without giving the result ( DWJ668 )! In 1977 I bought for my son starting at school a calculator. It was a yellow one in the shape of a monkeys face. He had to give the answers himself and the eyes of the monkey were blinking green if OK and red if false. The bad news ... The teacher was confiscating it ! and he never returned it (probably to use it himself ?). Calculators were still expensive at that time. Then I wrote the "hangman" program on my HP85. Perhaps Mon213 can find a "hangman" example in SB.

PS : If somebody knows about this monkey-calculator it would be great to offer it to a museum.

```Results = 0
While "True"
TextWindow.Write("Enter the first number:  ")
TextWindow.Write("Enter the second number: ")
TextWindow.WriteLine("Which calculation: 1=add  2=subtract  3=multiply  4=divide")

If calc=1 Then
ans=numb1+numb2
ElseIf calc=2 Then
ans=numb1-numb2
ElseIf calc=3 Then
ans=numb1*numb2
ElseIf calc=4 Then
ans=numb1/numb2
Else
TextWindow.WriteLine("This number is not allowed")
TextWindow.Pause()
Program.End()
EndIf
If Result <> ans Then
TextWindow.WriteLine("The answer is wrong ! Results set to : Zero : 0")
else
Results=results+1
TextWindow.WriteLine("GOOD JOB ! Results set to : "+Results)
EndIf
EndWhile```

`Hey very fast answer - probably this one https://picclick.fr/Vintage-Radio-Shack-Tandy-Monkey-See-Game-Calculator-274351891347.html and probably a small mistake in the program of jan (numb2 in stead of numb1)`
```If calc=1 Then
ans=numb1+numb2    ```

Thursday, May 7, 2020 7:12 PM
• ```If calc=1 Then
ans=numb1+numb2    ```

Hi Eddy, you are right. I quickly wrote that program to get Monk213 started.

I thought I tested all possible combinations, but I missed that one.

Thanks.

Jan [ WhTurner ] The Netherlands

Friday, May 8, 2020 9:26 AM
• You could break it down this way.

1. Create a Calculator that does what you need it to do.

2. Create a code for a password.

3. Integrate the password into the calculator program.

Following these three steps would help you to ease the path of program creation.

Friday, May 8, 2020 9:29 AM
• Yes but … I don’t see why you need a password to access a simple calculator !

Small basic is free, fun,  and an “educational” program language and needs to stay it, just as mathematics. One of the only fun examples I know is the “Monkey Anti-calculator”. You need to know the answer as password to verify your result!

All over the world in all languages in classic mathematics 2+2=4 ! (even with the first program of Jan). But the discussion needs to stay open and other approaches needs to stay possible. Mathematics and informatics are just an “abstract”  tool , and as such different from engineering, etc.

In an educational environment you need to explain what you are calculating, the algorithms that are behind, the precision of the results, etc. Just presenting a solution “as such” can never be the goal.

A simple search on “small basic calculator”, "passwords", etc  could give already plenty of solutions, such as the example of Jan. You can also find explanations with lesson 3-5 control objects calculator … a must of the excellent book “the-developers-reference-guide-to-small-basic” by  Ed.Price (today online).

You also have YouTubes such as in the small Basic Tutorial 4 Simple calculator …

A more complex calculator “Calculator v.1.0 by alex_2000”  :  KWR 934

One of Nonki : http://www.nonkit.com/en/smallbasic/index.html : BQJ710-3

Passwords : … just have a look on HGN676

If you want a  list of applications …

https://fr.slideshare.net/judeoashiedu/small-basic-calculator-apps-lesson

etc

Saturday, May 9, 2020 8:21 AM
• I think my question in the first answer is relavant: "Is this a school assignment?"

This was triggerd by the wording of the topioc e.g. "the program must prompt the user"

All the given links in the answers could be far to difficult for the TS, lets wait for an answer from him.

Jan [ WhTurner ] The Netherlands

Saturday, May 9, 2020 11:14 AM
• ok so i should have said this before to clear things up this is not a school assignment this something a friend sent me and i asked for a challenge

in no way shape or form am i cheating im just curious i have been wanting to get into small basic for awhile so i asked my friend and he sent me this challenge yes i asked for a challenge thought i could get right into it

Scottish monk

Monday, May 11, 2020 12:45 PM