Author Topic: How do I prompt a string?  (Read 3344 times)

0 Members and 1 Guest are viewing this topic.

Offline breebreebran

  • LV0 Newcomer (Next: 5)
  • Posts: 1
  • Rating: +0/-0
    • View Profile
How do I prompt a string?
« 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
« Last Edit: December 04, 2013, 06:56:52 pm by breebreebran »

Offline ClrDraw

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 627
  • Rating: +61/-2
    • View Profile
    • GitHub
Re: How do I prompt a string?
« Reply #1 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.
« Last Edit: December 05, 2013, 10:53:19 am by ClrDraw »
Visit my GitHub for all my TI programs as well as other projects.
Also check out my website.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: How do I prompt a string?
« Reply #2 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

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: How do I prompt a string?
« Reply #3 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.