The Cage Complex, thanks for your post. The main reason i like doing it the way im doing it is because it also shows all the working for the equation. Heres the next version of my simple equation solver, it now suports all 3 equations types, it does not yet surport 3x / 4 = 10 types of equations. It still requires a bit of work but for now im going to leave it at that and move on to a program for solveing simutanous equations.
equation solver v0.3
Rem Project: Algebra Equations
Rem Created: 3/09/2005 7:26:17 AM
Rem ***** Main Source File *****
sync on : sync rate 60
_main:
`Make our varibles Global for easy use in functions
global a# = 0
global TheVariToFind$
global TheEquationsOperation$
global EquationsType#
global b# = 0
global c# = 0
global d# = 0
global e# = 0
global g# = 0
SET CURSOR 0,45 : SET TEXT SIZE 12
global resetVari# = 0
`start the Main loop
do
if shiftkey() = 1
EXECUTE FILE "Algebra Equations.exe", "","",1
end
endif
`if space key = 1 then start the program
if resetVari# = 0 and spacekey() = 1
Gosub _setup_normal_Equations
endif
`refresh the screen
sync
loop
return
_setup_normal_Equations: `Eg 3y + 27 = 11
text 0,6,"Please select one of the following, by eg. 1 ,2 , 3 etc. 1. 2v = 18 "
text -6,20," 2. 2x -/+ 7 = 11 3. 30 - 2x = 14 4. m / 4 = 5"
input "enter type of Equation : ",EquationsType#
input "Please enter if its a +,- equation eg. 3y + 27 = 15 would be + : ",TheEquationsOperation$
`This stars our type 1 equation solver for no particular
if EquationsType# = 1 and TheEquationsOperation$ = ""
EquationType1()
endif
`This starts our type 2 equation solver for the operation +
if EquationsType# = 2 and TheEquationsOperation$ = "+"
EquationsType2Plus()
endif
`This starts our type 2 equation solver for the operation -
if EquationsType# = 2 and TheEquationsOperation$ = "-"
EquationsType2Minus()
endif
`This starts our type 3 equation solver for the operation -
if EquationsType# = 3 and TheEquationsOperation$ = "-"
EquationType3Minus()
endif
return
`This is the Function that solves the type 1 equation eg. 2x = 18
Function EquationType1()
`These take input from the user and stores them in a varible for calculations.
input "Please enter your first number Of the equation Eg 2v = 18 would be 2 : ",a#
input "Please enter your second number eg. 2v = 18 would be v : ",TheVariToFind$
input "Please enter the varible to be solved eg. 2v = 18 would be 18 : ",b#
`This displays the users equation on the screen.
text -6,160," your equation is :" + str$(a#) + ( TheVariToFind$ ) + " = " + str$(b#)
text -6,190,"this is possible answer : " + str$(b#) + " / " + str$(a#)
`This displays the step involved to calculate the equation
text 0,230,"step 1 : " + str$(a# ) + TheVariToFind$ + " / " + str$(a#) + " = " + str$(b#) + " / " + str$(a#)
`calculate the equation for later display
c# = b# / a#
`This displays the calculated varible
text 0,260,"Varible = : " + TheVariToFind$ + " = " + str$(c#)
`perform a action to check that the answer is correct.
text 0,290,"check : " + str$(a#) + " * " + str$(c#) + " = " + str$(b#)
endfunction
`This is the Function that solves the type 2 equation eg. 3y + 27 = 15
Function EquationsType2Plus()
`These take input from the user and stores them in a varible for calculations.
input "Please enter your first number Of the equation Eg 3g would be 3 : ",a#
input "Please enter the varible to be solved eg. 3y would be y : ",TheVariToFind$
input "Please enter your second number eg. 3g - 17 = 10 would be 17 : ",b#
input "Please enter the final = number Eg. 3g - 17 = 10 would be 10 : ",c#
`This displays the users equation on the screen.
text -6,160," your equation is :" + str$(a#) + ( TheVariToFind$ ) + ( TheEquationsOperation$ ) + str$(b#) + " = " + str$(c#)
`This displays step 1 involved in calculateing the equation
text 0,210,"step 1 : " + str$(a# ) + TheVariToFind$ + TheEquationsOperation$ + str$( b#) + " - " + str$(b#) + " = " + str$(c#) + " - " + str$(b#)
`this calculates step 1 in the equation
d# = c# - b#
`This displays step 2 involved in calculateing the equation
text 0,230,"step 2 : " + str$(a# ) + TheVariToFind$ + " / " + str$(a#) + " = " + str$(d#) + " / " + str$(a#)
`this calculates step 2 in the equation
e# = d# / a#
`This displays the calculated varible
text 0,260,"Varible = : " + TheVariToFind$ + " = " + str$(e#)
`perform a action to check that the answer is correct.
text 0,290,"check : " + str$(a#) + " * " + str$(e#)+ " + " + str$(b#) + " = " + str$(c#)
endfunction
`This is the Function that solves the type 2 equation eg. 2x - 7 = 11
Function EquationsType2Minus()
`These take input from the user and stores them in a varible for calculations.
input "Please enter your first number Of the equation Eg 3g would be 3 : ",a#
input "Please enter the varible to be solved eg. 3y would be y : ",TheVariToFind$
input "Please enter your second number eg. 3g - 17 = 10 would be 17 : ",b#
input "Please enter the final = number Eg. 3g - 17 = 10 would be 10 : ",c#
`This displays the users equation on the screen.
text -6,160," your equation is :" + str$(a#) + ( TheVariToFind$ ) + ( TheEquationsOperation$ ) + str$(b#) + " = " + str$(c#)
`This displays step 1 involved in calculateing the equation
text 0,210,"step 1 : " + str$(a# ) + TheVariToFind$ + TheEquationsOperation$ + str$( b#) + " + " + str$(b#) + " = " + str$(c#) + " + " + str$(b#)
`this calculates step 1 in the equation
d# = c# + b#
`This displays step 2 involved in calculateing the equation
text 0,230,"step 2 : " + str$(a# ) + TheVariToFind$ + " / " + str$(a#) + " = " + str$(d#) + " / " + str$(a#)
`this calculates step 2 in the equation
e# = d# / a#
`This displays the calculated varible
text 0,260,"Varible = : " + TheVariToFind$ + " = " + str$(e#)
`perform a action to check that the answer is correct.
text 0,290,"check : " + str$(a#) + " * " + str$(e#)+ " - " + str$(b#) + " = " + str$(c#)
endfunction
`This is the Function that solves the type 3 equation eg. 2x - 7 = 11
Function EquationType3Minus()
`These take input from the user and stores them in a varible for calculations.
input "Please enter your first number Of the equation Eg 30 would be 30 : ",a#
input "Please enter your second number eg. 30 - 5x = 10 would be -5 : ",b#
input "Please enter the varible to be solved eg. 5x would be x : ",TheVariToFind$
input "Please enter the final = number Eg. 30 - 5x = 10 would be 10 : ",c#
`This displays the users equation on the screen.
text -6,160," your equation is :" + str$(a#) + str$(b#) + ( TheVariToFind$ ) + " = " + str$(c#)
`This displays step 1 involved in calculateing the equation
text 0,210,"step 1 : " + str$(a# ) + str$( b#)+ TheVariToFind$ + " - " + str$(a#) + " = " + str$(c#) + " - " + str$(a#)
`this calculates step 1 in the equation
d# = c# - a#
`This displays step 2 involved in calculateing the equation
text 0,230,"step 2 : " + str$(b# ) + TheVariToFind$ + " / " + str$(b#) + " = " + str$(d#) + " / " + str$(b#)
`this calculates step 2 in the equation
e# = d# / b#
`This displays the calculated varible
text 0,260,"Varible = : " + TheVariToFind$ + " = " + str$(e#)
`perform a action to check that the answer is correct.
text 0,290,"check : " + str$(a#) + str$(b#)+ " * " + str$(e#) + " = " + str$(c#)
endfunction
`This is the Function that solves the type 3 equation eg. 2x - 7 = 11
Function EquationType4()
`These take input from the user and stores them in a varible for calculations.
input "Please enter your first number Of the equation Eg 30 would be 30 : ",a#
input "Please enter your second number eg. 30 - 5x = 10 would be -5 : ",b#
input "Please enter the varible to be solved eg. 5x would be x : ",TheVariToFind$
input "Please enter the final = number Eg. 30 - 5x = 10 would be 10 : ",c#
`This displays the users equation on the screen.
text -6,160," your equation is :" + str$(a#) + str$(b#) + ( TheVariToFind$ ) + " = " + str$(c#)
`This displays step 1 involved in calculateing the equation
text 0,210,"step 1 : " + str$(a# ) + str$( b#)+ TheVariToFind$ + " - " + str$(a#) + " = " + str$(c#) + " - " + str$(a#)
`this calculates step 1 in the equation
d# = c# - a#
`This displays step 2 involved in calculateing the equation
text 0,230,"step 2 : " + str$(b# ) + TheVariToFind$ + " / " + str$(b#) + " = " + str$(d#) + " / " + str$(b#)
`this calculates step 2 in the equation
e# = d# / b#
`This displays the calculated varible
text 0,260,"Varible = : " + TheVariToFind$ + " = " + str$(e#)
`perform a action to check that the answer is correct.
text 0,290,"check : " + str$(a#) + str$(b#)+ " * " + str$(e#) + " = " + str$(c#)
endfunction
Dark_angel