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

Click For Summary
The discussion focuses on improving the user interface of a program designed for finance calculations by replacing single-letter prompts with more descriptive strings. The user aims to prompt for inputs like "Ending Balance?", "Rate?", "Number of compounds?", and "Time?" instead of using single letters. This change is intended to enhance clarity and aesthetics in the program's output. However, the user encounters syntax errors when attempting to implement string prompts. Suggestions include using a print statement before each prompt or checking if the prompt command allows for a string parameter. Additionally, the type of calculator being used may affect the implementation of these changes.
breebreebran
Messages
12
Reaction score
0
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?
 
Computer science news on Phys.org
Well you put a print statement in front of each prompt.
 
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.
 
Thread 'ChatGPT Examples, Good and Bad'
I've been experimenting with ChatGPT. Some results are good, some very very bad. I think examples can help expose the properties of this AI. Maybe you can post some of your favorite examples and tell us what they reveal about the properties of this AI. (I had problems with copy/paste of text and formatting, so I'm posting my examples as screen shots. That is a promising start. :smile: But then I provided values V=1, R1=1, R2=2, R3=3 and asked for the value of I. At first, it said...

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
11K
  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 8 ·
Replies
8
Views
10K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
12
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 34 ·
2
Replies
34
Views
4K
  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 9 ·
Replies
9
Views
2K