Don't have an account? Register now to chat, post, use our tools, and much more.
I have created some programs for some random things in my classes. My current program is dealing with percentages and what I want it to do is to add all the inputs together once the program is done. Obvously it's not as simple as just A+b+c->d.
What I have is a single program that does the calculations, then when it finishes the calculations it asks for "Finished? Y/N", and you put in Y or N. N ends the program, Y does a "goto" back above.

So what I want it to do is when I click Y, it saves the previous number, goes through the program again, then adds it to make a cumulative percentage of both. Is there any way to get a program to save the variables together.

To make a better point of what I mean, I will write the program here. when I do "=" it's actually -> or the sto-> command for ease of use
Program: factoria
Disp: "successful probability?"
Input P
1-P=q
prompt N
lbl x
prompt B
n-b=c
(N!)/((b!)*c!))=D
D*p^B*q^c=e
Disp "PDF,Mean,Sigma"
Disp E,Z,W
Disp "continue?"
Input "y/n",Str1
then
goto x
else
end

So what I want it actually to do is, save E, (Z, and W, the mean and sigma will not change) then when you go to Y, and do the problem again, is to add the TWO E's together, then display them AFTER you click N. Hypothetically, if you continued the program a bunch of times, say 10 times, it adds the 10 different numbers together, then displays them at the end.

I don't really know if this is possible to do, I don't know how to get the numbers to save, then add at the end.

Side not, if you're in statistics, nCr, is n choose r, which is the factorial equation that I was doing, doesn't work in program? nCr is a lot more efficient, as it does the equations a little differently. When you do factorials, you can divide out numbers to make the numbers smaller, thus preventing a "overflow" in most cases. However, nCr doesn't work right in programs? Is there some way to use nCr in a program? and have the variables go into a nCr? Hypothetically, having it be "n"C"b"->D is more efficient than the weird factorial thing I made. Overflows are HUGELY common with factorials, because it's multiplying by all numbers below it. So 5! would be 5x4x3x2x1, so when you get into the 100s you deal a lot with overflows.

Any ideas how to get these to add cumulatively and to get nCr to work in program? Also, if you have any suggestions to the program that would make it more efficient I'd love to hear it, love to take notes on how to make it better to have it work in different programs. Such thing would be to have the Continue, y/n, be click enter on yes or no. Rather than to have to do Alpha 1 for y and alpha log for n. Don't really know if it's possible though.
I missed a part

input "(y/n)",str1
if str1="y"
goto x
else
end
Stop for a second and tell us what you are trying to accomplish with this code. What is the goal; i.e. what are the inputs and what should the outputs be? Avoid using any of your code when explaining. This will help us try to narrow down what you want to do

Edit: Also I'm not sure what you mean by not being able to use nCr, I just did "20 nCr 8->A" and A became 125970 so.....
When you want to store a variable amount of values, I suggest storing them in a list (or a matrix) so you can add them all together at the end of the program. This way you'll have the values seperately and cumulated as well. If you want the user to be able to click Yes or No, a "Menu(" command is recommandable. Also, you seem to have trouble using the binomial distribution manually, but doesn't your calculator just allow "binompdf("?

NOTE: When posting code, use the code brackets,
Code:
`like this`
MateoConLechuga wrote:
Stop for a second and tell us what you are trying to accomplish with this code. What is the goal; i.e. what are the inputs and what should the outputs be? Avoid using any of your code when explaining. This will help us try to narrow down what you want to do

Edit: Also I'm not sure what you mean by not being able to use nCr, I just did "20 nCr 8->A" and A became 125970 so.....

I explained what I wanted, I want them to add up after each run though. ncr doesn't work, I want variables to be placed inside. Such as A ncr B->C. Not just static numbers.
BasicTH wrote:
When you want to store a variable amount of values, I suggest storing them in a list (or a matrix) so you can add them all together at the end of the program. This way you'll have the values seperately and cumulated as well. If you want the user to be able to click Yes or No, a "Menu(" command is recommandable. Also, you seem to have trouble using the binomial distribution manually, but doesn't your calculator just allow "binompdf("?

NOTE: When posting code, use the code brackets,
Code:
`like this`

Extremely helpful. The menu command was exactly what I needed. And I didn't actually know how to use binomial pdf. Thanks. This list /matrix idea sounds very good. How would you h go about having them be stored in a list automatically though?
kwiksilver wrote:
How would you h go about having them be stored in a list automatically though?

You mean automatically as in that the program does it for you? Just make it do this:

Code:
```//At the start of the program :1->I :1->dim(ʟ1) //Creates list ʟ1, this is the ʟ1 token on your calc, not literally "ʟ1" //When E has been calculated :E->ʟ1(I) //Stores E in ʟ1 at index I (List indices start at 1) //When the user answers "Yes" :I+1->I //Add 1 to I, to continue to the next index :I->dim(ʟ1) //Enlarges ʟ1 with one element //When adding all the elements and storing them in, let's say, S :0->S :For(J,1,I) :S+ʟ1(J)->S :End```

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.

»
» All times are GMT - 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