Answered by:
Beginner wanting help with ideas for projects.
Question

Hi guys, I'm a 17 yearold who has been coding websites since the age of 11, I am proficient with XHTML, CSS and some Javascript; I've decided that I'd like to try my hand at programing and a friend suggested that I start with Small Basic.
I would really like to make some mathematical calculators using Small Basic, I would especially like to make some involving the following formulae:
 Volume of a Sphere
 Quadratic Equation
 Kinetic Energy
If you could be kind enough to point me to the tutorial(s) from which I can acquire the knowledge to do this I would be very greatfull.Ok, I've managed to do the volume of a sphere and kinetic energy, but need help with Quadratic Equation solver...
 Edited by Sam .223 Saturday, September 25, 2010 7:10 PM
Answers

Quadratic Equation Solver:
TextWindow.WriteLine("The equation is a^2*x + b*x + c = 0.") TextWindow.Write("Type A: ") ANumber = TextWindow.ReadNumber() TextWindow.Write("Type B: ") BNumber = TextWindow.ReadNumber() TextWindow.Write("Type C: ") CNumber = TextWindow.ReadNumber() TextWindow.WriteLine("Please wait... Counting.") Delta = BNumber * BNumber  (4 * ANumber * CNumber) If Delta < 0 Then TextWindow.WriteLine("ERROR: THERE ARE NO X's THAT SOLVE EQUATION.") Else If Delta = 0 Then DeltaSqrt = Math.SquareRoot(Delta) X = ( BNumber + DeltaSqrt) / (2 * ANumber) TextWindow.WriteLine("X: " + X) Else X1 = ( BNumber + DeltaSqrt) / (2 * ANumber) X2 = ( BNumber  DeltaSqrt) / (2 * ANumber) TextWindow.WriteLine("X1: " + X1) TextWindow.WriteLine("X1: " + X1) EndIf EndIf
 Marked as answer by Sam .223 Saturday, September 25, 2010 7:30 PM

I'M WORKING SO HARD: MARK ME AS ANSWER.
The GoodMorning program:
If Clock.Hour < 6 Then TimeOfDayText = "It's night! Why aren't You sleeping?" EndIf If Clock.Hour >= 6 And Clock.Hour < 12 Then TimeOfDayText = "Good Morning!" EndIf If Clock.Hour >= 12 And Clock.Hour < 18 Then TimeOfDayText = "Good Afternoon!" EndIf If Clock.Hour >= 18 And Clock.Hour < 22 Then TimeOfDayText = "Good Evening!" EndIf If Clock.Hour >= 22 And Clock.Hour < 24 Then TimeOfDayText = "Go To Bed!!!!!!" EndIf 'CHECK THE Clock.Hour property in action (I don't have Small Basic running now, so I can't really test it). GraphicsWindow.ShowMessage("Thanks for running my app.", TimeOfDayText)
 Proposed as answer by Jacob Brown Saturday, September 25, 2010 7:48 PM
 Marked as answer by Sam .223 Saturday, September 25, 2010 8:08 PM

Try this:
ContinueCalculations = "True" While ContinueCalculation = "True" ''' TO DO: PERFORM CALCULATIONS CODE HERE ''' ASK THE USER IF HE/SHE WANTS TO DO MORE: TextWindow.Write("Perform another calculation: (Y/N)") CCAnswer = TextWindow.Read() If CCAnswer = "N" Then ContinueCalculations = "False" EndIf EndWhile '''' TO DO: INSERT ACTIONS TO DO AFTER PERFORMING ALL THE CALCULATION, for example: thank the user for using Your app
 Proposed as answer by Jacob Brown Saturday, September 25, 2010 7:48 PM
 Marked as answer by Sam .223 Saturday, September 25, 2010 8:09 PM

All replies

This is a SMALL BASIC forum, and Small Basic is something totally different then Visual Basic. For more info on Visual Basic visit: http://msdn.microsoft.com/enus/vbasic/ms789086.aspx.
Small Basic is a simplified version for educational purposes. For more info visit: http://smallbasic.com/
If You would be interested in Small Basic, take a look at:
Type "Small Basic" in Google for more. 

If You are in Small Basic (not in Visual Basic) then:
TextWindow.Write("Speed: ") speed = TextWindow.ReadNumber() TextWindow.Write("Mass: ") mass = TextWindow.ReadNumber() kineticEnergy = speed * speed * mass / 2 TextWindow.WriteLine("Kinetic Energy: " + kineticEnergy + ".")
 Proposed as answer by Jacob Brown Saturday, September 25, 2010 7:17 PM




Of course mate, I'm afraid I have another question: Is it possible to request a password? Oh and I'd like to be able to say "Good x" depending on the time of day, morning, afternoon or evening. :)
The way you made your kinetic energy calculator is much more elegant than mine  thank you very much for your insight. How do I display powers in .Write("")? like x²?

Quadratic Equation Solver:
TextWindow.WriteLine("The equation is a^2*x + b*x + c = 0.") TextWindow.Write("Type A: ") ANumber = TextWindow.ReadNumber() TextWindow.Write("Type B: ") BNumber = TextWindow.ReadNumber() TextWindow.Write("Type C: ") CNumber = TextWindow.ReadNumber() TextWindow.WriteLine("Please wait... Counting.") Delta = BNumber * BNumber  (4 * ANumber * CNumber) If Delta < 0 Then TextWindow.WriteLine("ERROR: THERE ARE NO X's THAT SOLVE EQUATION.") Else If Delta = 0 Then DeltaSqrt = Math.SquareRoot(Delta) X = ( BNumber + DeltaSqrt) / (2 * ANumber) TextWindow.WriteLine("X: " + X) Else X1 = ( BNumber + DeltaSqrt) / (2 * ANumber) X2 = ( BNumber  DeltaSqrt) / (2 * ANumber) TextWindow.WriteLine("X1: " + X1) TextWindow.WriteLine("X1: " + X1) EndIf EndIf
 Marked as answer by Sam .223 Saturday, September 25, 2010 7:30 PM

Thank you very much for helping me so much. Could you provide an If statement that allows the user to choose whether they want to make another calculation (which displays directly below the first one,) or simply says "Thank you for using my program!"

I'M WORKING SO HARD: MARK ME AS ANSWER.
The GoodMorning program:
If Clock.Hour < 6 Then TimeOfDayText = "It's night! Why aren't You sleeping?" EndIf If Clock.Hour >= 6 And Clock.Hour < 12 Then TimeOfDayText = "Good Morning!" EndIf If Clock.Hour >= 12 And Clock.Hour < 18 Then TimeOfDayText = "Good Afternoon!" EndIf If Clock.Hour >= 18 And Clock.Hour < 22 Then TimeOfDayText = "Good Evening!" EndIf If Clock.Hour >= 22 And Clock.Hour < 24 Then TimeOfDayText = "Go To Bed!!!!!!" EndIf 'CHECK THE Clock.Hour property in action (I don't have Small Basic running now, so I can't really test it). GraphicsWindow.ShowMessage("Thanks for running my app.", TimeOfDayText)
 Proposed as answer by Jacob Brown Saturday, September 25, 2010 7:48 PM
 Marked as answer by Sam .223 Saturday, September 25, 2010 8:08 PM

Try this:
ContinueCalculations = "True" While ContinueCalculation = "True" ''' TO DO: PERFORM CALCULATIONS CODE HERE ''' ASK THE USER IF HE/SHE WANTS TO DO MORE: TextWindow.Write("Perform another calculation: (Y/N)") CCAnswer = TextWindow.Read() If CCAnswer = "N" Then ContinueCalculations = "False" EndIf EndWhile '''' TO DO: INSERT ACTIONS TO DO AFTER PERFORMING ALL THE CALCULATION, for example: thank the user for using Your app
 Proposed as answer by Jacob Brown Saturday, September 25, 2010 7:48 PM
 Marked as answer by Sam .223 Saturday, September 25, 2010 8:09 PM







A good way to learn is to convert a project from another similar language. Check out the online copies of these books:
Games in Basic: http://www.atariarchives.org/basicgames/
and
More Games in Basic: http://www.atariarchives.org/morebasicgames/
The games described are written in the old MS Basic interpreter from the late 70's and early 80's. The code is really horrible examples of proper programming practices, but getting them to work should give you a nice low level challenge.
And there is nothing more entertaining then working with game logic.
Good luck.