lionrocker221
lionrocker221

Reputation: 171

Prompt for mathematical expression of two variables, followed by evaluation

I would like the user to be prompted to input an expression "E" like 2X or Y+3X^2 or √(X+Y). Then I would like to evaluate "E" with specific values for X and Y and store the output.

Here's a high-level idea of what I want to achieve:

Prompt X, Y
Prompt E # expression in terms of X, Y
eval(E,X,Y)→O # evaluation of expression E given values of X, Y

Upvotes: 0

Views: 30

Answers (1)

SP4CEBAR
SP4CEBAR

Reputation: 21

This code should work:

Prompt X,Y
Prompt Str1
String►Equ(Str1,Y1)
Disp Y1

Where Str1, and Y1 are variables that can be found under your calculator's "vars" tab. Make sure to start your answer to the string prompt with double quotes. Otherwise, it is not a string and the program will throw a data type error.

Upvotes: 0

Related Questions