Hi, I made this graphing program the other day, and it works ok, except that it won't work right if i type in negative exponents! It began to graph half a hyperbola once, but I'm not sure what happened afterwards! Anyway, here is the code, and tell me if you can see what's wrong with it:
SCREEN 12
CLS
INPUT "What is the coefficient of x"; num1
INPUT "What is the power of x"; num2
INPUT "What number is added to the equation"; num3
PRINT
PRINT "Inputting a high value below will increase speed, at the cost of"
PRINT "quality. A lower value will be more detailed but slower. A recommended"
PRINT "value is anything between 1 and 10."
INPUT "What intervals are to be set for each value of x"; value
INPUT "And finally, what color (1-14) do you want your graph in?"; co
CLS
LINE (320, 0)-(320, 480)
LINE (0, 240)-(640, 240)
Y = num1 * x ^ num2 + num3
top:
x = x + value / (10 ^ 3)
IF x > 30 THEN GOTO top2
Y = num1 * x ^ num2 + num3
PSET (320 + x * 15, 240 - Y * 15), co
GOTO top
top2:
x = x - value / (10 ^ 3)
IF x < -30 THEN GOTO finish
Y = num1 * x ^ num2 + num3
PSET (320 + x * 15, 240 - Y * 15), co
GOTO top2
finish:
INPUT "You may input more if you wish. Y/N"; Y$
IF Y$ = "Y" THEN GOTO begin
IF Y$ = "y" THEN GOTO begin
IF Y$ = "N" THEN END
IF Y$ = "n" THEN END
SCREEN 12
CLS
INPUT "What is the coefficient of x"; num1
INPUT "What is the power of x"; num2
INPUT "What number is added to the equation"; num3
PRINT "Inputting a high value below will increase speed, at the cost of"
PRINT "quality. A lower value will be more detailed but slower. A recommended"
PRINT "value is anything between 1 and 10."
INPUT "What intervals are to be set for each value of x"; value
INPUT "And finally, what color (1-14) do you want your graph in?"; co
CLS
LINE (320, 0)-(320, 480)
LINE (0, 240)-(640, 240)
Y = num1 * x ^ num2 + num3
top:
x = x + value / (10 ^ 3)
IF x > 30 THEN GOTO top2
Y = num1 * x ^ num2 + num3
PSET (320 + x * 15, 240 - Y * 15), co
GOTO top
top2:
x = x - value / (10 ^ 3)
IF x < -30 THEN GOTO finish
Y = num1 * x ^ num2 + num3
PSET (320 + x * 15, 240 - Y * 15), co
GOTO top2
finish:
INPUT "You may input more if you wish. Y/N"; Y$
IF Y$ = "Y" THEN GOTO begin
IF Y$ = "y" THEN GOTO begin
IF Y$ = "N" THEN END
IF Y$ = "n" THEN END