Search code examples
javati-basic

How to display a string and a number on the same line and use if statements in TI-Basic


EDIT: I found the answer! I commented it below

I have a TI-84 Plus C Silver Edition
So this is my code:

Prompt A,B,C
((-B+√(B²-4AC))/(2A))->X
((-B-√(B²-4AC))/(2A))->Y
Disp X,Y

So that works completely fine, but I want to add code at the end that works like this(This is how I would write it in Java):

if(X % 1 == 0 && Y % 1 == 0){
    System.out.println("(x-" + X + ")(x-" + Y + ")");
}

But I don't know how to format that, or even get the disp statement working, because it throws an error(data type or something).
It's not really required, but I atleast want to learn how to do it.

Thanks in advance!

EDIT:

So when I try this code:

disp "(x-" +X+ ")(x-" +Y+ ")"

It returns an error:
"ERROR: DATA TYPE
Wrong value or variable type entered.
Ex: Attempted to store a matrix to a list."

So I get that it's looking for only a string or only a number, but I don't know what to do.


Solution

  • Ok so after a google search, I found the answer
    You have to convert the number to a string(http://tibasicdev.wikidot.com/number-to-string), and then you can concatenate the strings normally in the disp command.
    Ex:

    disp "(x-"+Str1+")(x-"+Str2+")"