I am making a program that will give C, A, B, and D of the equation Y=C+AcosB(θ-D) when you are given the graph. I have the base program down and it works but when I am not given a min or max it doesn't work. See pics of the problems I'm trying to solve at http://imgur.com/a/it1q1

C is found by averaging max and min
A is found by max minus C
B is found by 360/length of period
D is found by first max

In the beginning I need to ask if C is given and if it is I need to find either max or min and then continue the program.


Code:
output(4,1,"1 for yes
output(5,1,"0 for no
input "is C given? ",O
if O=1
then
clrhome
output(3,1,"1 for max
output(4,1,"2 for min
input "max or min given? ",K
input "C=",C
if K=1
then
input "max: ",X
2C-X→Y
else
input "min: ",Y
2C-Y→X
Goto R
else
(code that gets run if max and min are given)

Lbl R
(code after C is found)


The error I get is that when it gets to the else after Goto R in the code, is syntax.
Also, if I say that C is given it says done on the screen and nothing is executed.
You have If/Then/Else/Else. You can't have two Else clauses for a single If/Then. Also, you're Goto'ing out of an If/Then/[Else/]End, which is one of the best ways to create memory leaks.
I was trying to have the if k=1 then blahblah else as a nested loop inside of the then part of the if O=1 statement. How do I clear this up?
How do I avoid goto'ing out without having to basically rewrite the whole prog?
Then I think you want something like this:


Code:
If <condition 1>
Then
   If <condition 2>
   Then
      <stuff>
   Else
      <other stuff>
   End
Else
   <more stuff>
End
(The indentation is for clarity and should not be included in the program, of course.
  
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