Hey guys,

I'm trying to make a program that should be fairly simple. It's just a fancy way of displaying the quadratic formula. By pressing up and down, you should be able to insert A, B and C. However, I have a few problems. Anyone who can help me?


Code:


0→U:0→D:0→Y:0→Z:0→K

Lbl A

ClrHome


Output(2,3,B
Output(2,1,"B=")
Output(3,3,C
Output(3,1,"C=")

Output(5,3,D
Output(5,1,"D=

Output(7,3,Y
Output(7,1,"X=
Output(8,1,"OR
Output(9,3,Z
Output(9,1,"X=

Input "A=",A

B²-4AC→D
If D<0:Then
Output(1,3,A
Output(1,1,"A
Output(2,3,B
Output(2,1,"B=")
Output(3,3,C
Output(3,1,"C=")
Output(5,1,"D<0"

If 0=0:Then
Goto K
Else
Goto K

Else

((­B)-√(D))/(2*A)→Y
((­B)+√(D))/(2*A)→Z

If Y=Z:Then
Output(1,3,A
Output(1,1,"A
Output(2,3,B
Output(2,1,"B=")
Output(3,3,C
Output(3,1,"C=")
Output(5,3,D
Output(5,1,"D=
Output(7,3,Y
Output(7,1,"X=

Else

Output(1,3,A
Output(1,1,"A=
Output(2,3,B
Output(2,1,"B=")
Output(3,3,C
Output(3,1,"C=")

Output(5,3,D
Output(5,1,"D=

Output(7,3,Y
Output(7,1,"X=
Output(8,1,"OR
Output(9,3,Z
Output(9,1,"X=

End
End

1→U
If 0=0:Then
Goto K
Else
Goto K

Lbl K

0→K

getKey→K

If K=0
Goto K
If K=25 and U=3
Goto A
If K=25 and U=2
Goto C
If K=25 and U=1
Goto B
If K=34 and U=3
Goto B
If K=34 and U=1
Goto C
If K=34 and U=2
Goto A
If K=45
Goto Q
If K=105 and U=1
Goto A
If K=105 and U=2
Goto B
If K=105 and U=3
Goto C
If U=0
1→U

Lbl B

ClrHome

Output(2,3,C
Output(2,1,"C=")
Output(3,3,A
Output(3,1,"A=")

Output(5,3,D
Output(5,1,"D=

Output(7,3,Y
Output(7,1,"X=
Output(8,1,"OR
Output(9,3,Z
Output(9,1,"X=

Input "B=",B

B²-4AC→D
If D<0:Then
B²-4AC→D
If D<0:Then
Output(1,3,A
Output(1,1,"A
Output(2,3,B
Output(2,1,"B=")
Output(3,3,C
Output(3,1,"C=")
Output(5,1,"D<0"

Goto K

Else

((­B)-√(D))/(2*A)→Y
((­B)+√(D))/(2*A)→Z
Goto 99
Else
Goto 99


Lbl 99
If Y=Z:Then
Output(1,3,A
Output(1,1,"A
Output(2,3,B
Output(2,1,"B=")
Output(3,3,C
Output(3,1,"C=")
Output(5,3,D
Output(5,1,"D=
Output(7,3,Y
Output(7,1,"X=
Goto 69
Else
Goto 69
Lbl 69

Else

Output(1,3,B
Output(1,1,"B=
Output(2,3,C
Output(2,1,"C=")
Output(3,3,A
Output(3,1,"A=")

Output(5,3,D
Output(5,1,"D=

Output(7,3,Y
Output(7,1,"X=
Output(8,1,"OR
Output(9,3,Z
Output(9,1,"X=

Goto 44
Else
Goto 44
Lbl 44

End
End

Goto 55
Else
Goto 55
Lbl 55

2→U

If 0=0:Then
Goto K
Else
Goto K


Lbl C

ClrHome

Output(2,3,A
Output(2,1,"A=")
Output(3,3,B
Output(3,1,"B=")

Output(5,3,D
Output(5,1,"D=

Output(7,3,Y
Output(7,1,"X=
Output(8,1,"OR
Output(9,3,Z
Output(9,1,"X=

Input "C=",C

B²-4AC→D
If D<0:Then
B²-4AC→D
If D<0:Then
Output(1,3,A
Output(1,1,"A
Output(2,3,B
Output(2,1,"B=")
Output(3,3,C
Output(3,1,"C=")
Output(5,1,"D<0"

If 0=0:Then
Goto K
Else
Goto K

Else

((­B)-√(D))/(2*A)→Y
((­B)+√(D))/(2*A)→Z


If Y=Z:Then
Output(1,3,A
Output(1,1,"A
Output(2,3,B
Output(2,1,"B=")
Output(3,3,C
Output(3,1,"C=")
Output(5,3,D
Output(5,1,"D=
Output(7,3,Y
Output(7,1,"X=

If 0=0:Then
Goto K
Else
Goto K

Else

Output(1,3,C
Output(1,1,"C=
Output(2,3,A
Output(2,1,"A=")
Output(3,3,B
Output(3,1,"B=")

Output(5,3,D
Output(5,1,"D=

Output(7,3,Y
Output(7,1,"X=
Output(8,1,"OR
Output(9,3,Z
Output(9,1,"X=

End
End

3→U

If 0=0:Then
Goto K
Else
Goto K

Lbl Q

ClrHome



The

Code:
Goto K
Else
Goto K

is something I read on the internet to prevent the program from randomly stopping itself. However, this causes the answers for X never to update. It also has some other bugs with displaying and entering A, B and C. Since i just got into programming with BASIC, I'm completely lost. Does anyone know how I can fix my horrible, chunky code? :S
I don't really understand your program, and what it is supposed to do. Could you clarify?
Also, have you tried running the program without that bit of code? Just try running

Code:
Goto K
You are missing the 'End' for that if-statement.
PT_ wrote:
You are missing the 'End' for that if-statement.

Oh wow, I didn't even notice! I'll try putting it in.
Caleb_Hill wrote:
I don't really understand your program, and what it is supposed to do. Could you clarify?
Also, have you tried running the program without that bit of code? Just try running

Code:
Goto K


I'm sorry, it's extremely chunky. It's mostly a project for me to get more familiar with BASIC.
It's meant to calculate X in a quadratic formula in realtime. You can switch between input for A, B and C with the up and down keys. I'll try and compact it down a bit once it's done so it doesn't use over a KB of storage space.
Oh, and only running


Code:
Goto K

Just causes the program to crash. Not sure why though.
Well I've just dropped this buggy, chunky code. You won't see me here until I actually know what I'm doing. Thanks for the help though!
banaanstroop wrote:
Well I've just dropped this buggy, chunky code. You won't see me here until I actually know what I'm doing. Thanks for the help though!

If you need help writing the new program, you can ask for help here.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement