(03-23-2018 04:24 AM)Gamo Wrote: Solve a system of linear equations for two unknown variables.

This program solves for x and y, given the equation
aX + bY = e
cX + dY = f

Gamo, this is a nice and functional program. It works correctly and solves a common problem. And it also is a nice example where applying some basic rules of good programming style may make it much more reliable and robust. So I hope you do not mind when I take the opportunity to remind us all of a basic rule for better programming:

When a program stops with R/S for display or data entry, it is always a good idea not to rely on a certain stack content when the program continues. The user may have performed a calculation before he entered a value, or some other key may have been pressed that disturbs the stack. This would cause the program to continue with wrong data and thus wrong results.

Take a look at the R/S in line 12. The next steps rely on the fact that the T-register remains unchanged. The user only has to press a number key, and T is lost. Here the 3x Rv is not required at all, simply replace this with "RCL 4" and the problem cannot occur. The program will safely continue with the correct data.

Then take a look at line 28-30. The determinant is calculated and R/S displays it. But it has not been stored at this point. It is stored after the R/S. Imagine the user inadvertedly presses a key here: then the number that happens to be in X is stored in the next step as the (wrong) determinant and the complete calculation is void.

As a general rule you should always first store a result, then display it. And, if possible, always write the program in a way that does not rely on previous stack contents when the user continues with R/S. Always remember: the common user is a strange beast. He may press keys that you don't want him to press, so you better play safe and make sure that this does not cause unexpected problems.

All this can be done easily here:

- After all six coefficients have been entered, calculate the determinant, then store it, and finally, once it has been saved, display it.

- Then calculate X. Do not use previous stack content – all required data is available in the storage registers from where it can be safely recalled.

Any comment is very welcome. I like how you improve and make correction on how I program. I'm not the expert here and I like to learn on how to program it better. Each time that you give me a comment I look over, make change and try to improve the next time. Any suggestion is welcome too.

Very nice idea to also try to make the program as user friendly as possible so that to avoid any mistake.
I have learn that putting ..... 1 R/S and .....2 R/S to separate equation #1 and #2 then show Determinant with the next R/S so that not to confuse user.

(03-23-2018 12:02 PM)Gamo Wrote: Any comment is very welcome. I like how you improve and make correction on how I program.

Fine, thank you.

(03-23-2018 12:02 PM)Gamo Wrote: Very nice idea to also try to make the program as user friendly as possible so that to avoid any mistake.
I have learn that putting ..... 1 R/S and .....2 R/S to separate equation #1 and #2 then show Determinant with the next R/S so that not to confuse user.

All this looks even nicer if the display shows 1,111111–11 and 2,222222–22. This shows more clearly that this is a marker and not an entered number. You can see how this looks like if you store these two numbers in R7 and R8 and replace the "1" and "2" with RCL 7 and RCL 8. ;-)