Best Answer (*) , 09 August 2017 - 05:21 AM
The part
"ERROR: Not in range.
you forgot the last ",
It has to be: "ERROR: Not in range."
Go to the full postBest Answer (*) , 09 August 2017 - 05:21 AM
The part
"ERROR: Not in range.
you forgot the last ",
It has to be: "ERROR: Not in range."
Go to the full postPosted 09 August 2017 - 05:06 AM
Hello, all!
I just got my CASIO fx-9860GII SD and found out it was possible to program on it. (Yes, I've been living under a rock.)
I thought this was perfect for eliminating grunt work.
Anyway, I wrote this program which helps with factoring quadratic expressions.
The program brute forces through all the possible combination of E and F within an inputted range. It tries to find a combination that satisfies both E + F = B and E * F = D (where D is the product of A and C in the standard quadratic expression).
The problem is I keep getting a syntax error, and the cursor is at the end of the code right before the quotation mark. I skimmed through Ch. 8 of the manual, but the only thing I found is that the debugger doesn't always put the cursor in the correct place. I read the code a couple of times; I couldn't figure out what is wrong.
I thought might have a mistake with the while loop or the if statements because I come from C++ where you just put brackets, but I checked the syntax in the manual and it seemed correct.
(I also tried removing ""END"" but the syntax error went in between the F and the little triangle thing.)
Here is the code:
Filename:QUADSPLT "Ax^2+Bx+CãAx^2+Ex+Fx+C"Ù ""Ù "Enter range to search for E and F"Ù ?ãRÙ -RãEÙ -RãFÙ Ù "Enter A"Ù ?ãAÙ "EnterB"Ù ?ãBÙ "Enter C"Ù ?ãCÙ AÀCãDÙ Ù Ù While (EÀFÈD) And (E+FÈB)Ù If (E=R) And (F=R)Ù Then Ù "ERROR: Not in range.Ù StopÙ IfEndÙ Ù If E=RÙ Then Ù -RãEÙ F+1ãFÙ Else Ù E+1ãEÙ IfEndÙ WhileEndÙ Ù "E="Ù EØ "F="Ù FØ "END"
The formatting doesn't work that well on the browser, so here is a download to the G1M file: https://www.dropbox....ADSPLT.G1M?dl=0
Posted 09 August 2017 - 05:21 AM Best Answer
The part
"ERROR: Not in range.
you forgot the last ",
It has to be: "ERROR: Not in range."
Posted 09 August 2017 - 05:54 AM
The part
"ERROR: Not in range.you forgot the last ",
It has to be: "ERROR: Not in range."
Oh, I'm such an idiot. xD
I read the code like 20 times trying to figure out what is wrong.
Anyway, that fixes the syntax error, however, the results are not as expected (I don't think its the logic because I tried coding it in C++, and it works).
This is what I get when I input 10 for R, 2 for A, 5 for B ,3 for C:
E = -1
F = -6
I expected:
E = 3
F = 2
Should I start a new topic?
EDIT: Also do you know if there is a better way to program CASIO BASIC (like an actual IDE with a good debugger and colors )
Edited by hoobigii, 09 August 2017 - 05:59 AM.
Posted 09 August 2017 - 07:27 AM
Edited by user202729, 09 August 2017 - 07:28 AM.
Posted 09 August 2017 - 08:50 AM
It is the logic. "While (E*F!=D) Or (E+F!=B)" should be what you want.
And why can't you just use the quadratic formula?
That works now, thanks. It makes sense now that you brought it up to my attention
I'm am not using the quadratic formula because I am trying to make math more fun and not just do the math on the calculator. I find the factoring part really satisfying; however, find the two numbers whose product is a*c and sum up to b is really boring.
EDIT: Never mind. I'm an idiot; I typed in an or. Why didn't I notice that?!
Now I find it weird that my "prototype" works:
#include <iostream> int main() { std::cout << "Ax^2+Bx+C->Ax^2+Ex+Fx+C\n\n"; std::cout << "Enter range:"; int R; std::cin >> R; int E; int F; E = -R; F = -R; std::cout << "Enter A:"; int A; std::cin >> A; std::cout << "Enter B:"; int B; std::cin >> B; std::cout << "Enter C:"; int C; std::cin >> C; int D; D = A * C; while ((E*F!=D) || (E+F!=B)) { if (E == R) { E = -R; F++; } if ((E == R) || (F == R)) { std::cout << "ERROR: Not in range."; return -1; } E++; } std::cout << "E=" << E << "\n"; std::cout << "F=" << F << "\n"; return 0; }
Edited by hoobigii, 09 August 2017 - 08:56 AM.
Programming →
Casio Basic →
ASCII conversion table on fx G seriesStarted by Just_A_Noob_Here , 20 Jul 2024 ascii, casio, programming and 4 more... |
|
|
||
Calculators →
Casio CFX/AFX/FX/Prizm →
Audio player programStarted by NIPro , 22 May 2024 Audio Player, CFX, Casio, 9850 and 3 more... |
|
|
||
Answered
Calculators →
Casio CFX/AFX/FX/Prizm →
Where i can buy FA-123 cable for cheap?Started by NIPro , 23 Mar 2024 Cable, FA-123, FA-124, CFX, Casio and 5 more... |
|
|
||
Programming →
Casio Basic →
How to reach If, Mat and other functions on fx-9700GEStarted by Lovistovis , 22 Sep 2022 fx-9700GE, Casio Basic |
|
|
||
General →
Your Projects →
Casio BASIC editorStarted by Tritonio , 11 Sep 2022 basic, editor |
|
|
0 members, 0 guests, 0 anonymous users