Answered by:
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
Answers

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.
 Proposed as answer by Ed Price  MSFTMicrosoft employee Wednesday, May 13, 2020 9:22 PM
 Marked as answer by WhTurner33Editor Thursday, June 4, 2020 9:54 AM
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
 Edited by WhTurner33Editor Monday, May 4, 2020 1:08 PM typo
Monday, May 4, 2020 1:07 PMAnswerer 
As a starter a simple calculator
TextWindow.Write("Enter the first number: ") numb1=TextWindow.ReadNumber() TextWindow.Write("Enter the second number: ") numb2=TextWindow.ReadNumber() TextWindow.WriteLine("Which calculation: 1=add 2=subtract 3=multiply 4=divide") calc=TextWindow.ReadNumber() If calc=1 Then ans=numb1+numb1 ElseIf calc=2 then ans=numb1numb2 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
 Proposed as answer by Ed Price  MSFTMicrosoft employee Thursday, May 7, 2020 7:00 AM
Monday, May 4, 2020 5:34 PMAnswerer 
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 monkeycalculator it would be great to offer it to a museum.
Results = 0 While "True" TextWindow.Write("Enter the first number: ") numb1=TextWindow.ReadNumber() TextWindow.Write("Enter the second number: ") numb2=TextWindow.ReadNumber() TextWindow.WriteLine("Which calculation: 1=add 2=subtract 3=multiply 4=divide") calc=TextWindow.ReadNumber() TextWindow.WriteLine("What is your result ?") Result=TextWindow.ReadNumber() If calc=1 Then ans=numb1+numb2 ElseIf calc=2 Then ans=numb1numb2 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/VintageRadioShackTandyMonkeySeeGameCalculator274351891347.html
and probably a small mistake in the program of jan (numb2 in stead of numb1)If calc=1 Then ans=numb1+numb2
 Edited by Eddy Abts Friday, May 8, 2020 6:27 AM
 Proposed as answer by Ed Price  MSFTMicrosoft employee Wednesday, May 13, 2020 9:22 PM
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 AMAnswerer 
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.
 Proposed as answer by Ed Price  MSFTMicrosoft employee Wednesday, May 13, 2020 9:22 PM
 Marked as answer by WhTurner33Editor Thursday, June 4, 2020 9:54 AM
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 Anticalculator”. 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 35 control objects calculator … a must of the excellent book “thedevelopersreferenceguidetosmallbasic” by Ed.Price (today online).
You also have YouTubes such as in the small Basic Tutorial 4 Simple calculator …
https://www.youtube.com/watch?v=9p2sW9nkn08You
A more complex calculator “Calculator v.1.0 by alex_2000” : KWR 934
One of Nonki : http://www.nonkit.com/en/smallbasic/index.html : BQJ7103
Passwords : … just have a look on HGN676
If you want a list of applications …
https://fr.slideshare.net/judeoashiedu/smallbasiccalculatorappslesson
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
 Edited by WhTurner33Editor Saturday, May 9, 2020 11:15 AM typo
Saturday, May 9, 2020 11:14 AMAnswerer 
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