Can anyone explain how to store a string as a variable?

  • #1
I don't have any big programs. I just write programs to get me through my math classes.
But I want to have the output look pretty.
Like one program I have is for my finance class.

Code:
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

But what I want to do is instead of prompting p, I want to prompt "present value?"
Then If present value = 1 then etc.
It just looks neater if it prompts an entire string instead of one letter.
So instead of prompting b,r,n,t it'll prompt
"Ending Balance?"
"Rate?"
"Number of compounds?"
"Time?"
And then I can save those strings as variables.
So ending balance → b
Rate → r
Number of compounds → n
And then just have the rest of the program work with those letters instead of having to type out (rate/numberofcompounds)
Every time I try to use strings instead of letters it always gives me a syntax error.
Any help?
 

Answers and Replies

  • #3
34,981
6,734
breebreebran, you didn't say what kind of calculator you have, which would be useful information. It's possible that the prompt command has an optional first parameter of a string, like this:
prompt "Present value? ", p

If not, do as jedishrfu suggests, and print the string before executing the prompt.
 

Related Threads on Can anyone explain how to store a string as a variable?

  • Last Post
Replies
15
Views
4K
  • Last Post
Replies
23
Views
29K
Replies
1
Views
2K
Replies
7
Views
32K
  • Last Post
Replies
4
Views
2K
  • Last Post
Replies
6
Views
265
  • Last Post
Replies
9
Views
2K
Replies
9
Views
3K
Top