Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: breebreebran on December 04, 2013, 06:54:36 pm

Title: How do I prompt a string?
Post by: breebreebran on December 04, 2013, 06:54:36 pm
I'm using the ti 89 titanium.
I dont have any big programs. I just like to write programs to get me through my math classes.
Here's what all my programs look like.
Code: [Select]
prompt p
if p = 1
then
Prompt b,r,n,t
r/100→x
b/(1+x/n)^(n*t)→l
disp l
else
Prompt b,r,n,t  
r/100 → x  
b*(x/n)/((1+x/n)^(n*t)-1) → m  
disp m
As simple as that.
But what I want to do is instead of prompting p, I want to prompt a string of text.
This program is for my finance class.
So instead of asking for p it'll prompt "present value"
and then I can store that string as p.
So
"present value" → p
if p = 1 then etc
Or like the other prompt in my else.
Prompt b,r,n,t
I want to prompt
ending balance
rate
time
number of compounds
And then store them as a letter.
rate → r
time → t
It just looks prettier to me if it printed a string
Title: Re: How do I prompt a string?
Post by: ClrDraw on December 05, 2013, 10:52:44 am
On the ti 84 you can use:
Code: [Select]
:Input "Type:",Str1And the input will be stored in Str1. This should work on your calculator too. Input is found under PRGM > I/O on my calc, if you can't find it there than look in the catalog.
Title: Re: How do I prompt a string?
Post by: Sorunome on December 05, 2013, 11:07:37 am
The TI-89 works differently, but you can just use InputStr on all of your variables, so
Code: [Select]
InputStr myvar
Disp myvar
Title: Re: How do I prompt a string?
Post by: Xeda112358 on December 05, 2013, 11:21:13 am
This also works for the TI-89t, but you could also play with Dialog boxes, too, if you wanted to make it fancier. I don't know what P is since it isn't used in calculations, so I thought it was just an option:
Code: [Select]
Dialog
Title "Title"
Request "balance",b,0
Request "rate",r
Request "compounds",n
Request "time",t
DropDown "Option:",{"1","2"},p
EndDlog
However, as a warning, B,R,N, and T are strings, so you will need to use expr() on them to convert them to numbers to perform calculations.

You can also make your program into a function if that is easier, but that doesn't prompt for inputs. Still, you could do:
Code: [Select]
func1(b,r,n,t)
Func
Local b,r,n,t
Return b*(.01r/n)/((1+.01r/n)^(n*t)-1)
EndFunc
Then on the homescreen, you could use it just like a regular function.