(11C) Currency Converter
10-01-2018, 11:58 AM (This post was last modified: 10-01-2018 11:59 AM by Dieter.)
Post: #2
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: (11C) Currency Converter
(10-01-2018 06:00 AM)Gamo Wrote:  Program to convert "three" foreign exchange rates.

Gamo, I see you are using two techniques that have been used in earlier conversion programs:

1. Multiplying by a factor is done directly, while the inverse division is done by 1/x GSB A 1/x. This is a good idea if the conversion factor is hard-coded in the program so that it will occupy 8, 10 or more steps. This way the constant has to be coded only once. But here this does not apply: the factor is stored in a data register, so the 1/x GSB A 1/x method does not make much sense. A simple division (RCL 0 ÷) is shorter and runs much faster.

2. Using a sign for flagging input is a good idea to handle two different calculations, depending on whether the input is positive or negative. This makes sense if the user cannot directly access different parts of the program, for instance on the 12C: there are no labels, so the program is always started at the beginning with [R/S]. Here the sign of the input can make the program branch to different routines: positive? do this, negative? do that. But in our case the 11C offers five labels A...E that can be accessed directly. So the whole program can be coded much simpler:

Code:
LBL A  //convert to currency 1 RCL 0 x RTN LBL B  //convert from currency 1 RCL 0 ÷ RTN LBL C  //convert to currency 2 RCL 1 x RTN LBL D  //convert from currency 2 RCL 1 ÷ RTN

After storing the constants you simply press [A] or [B] to convert to/from Euros and [C] or [D] to convert to/from Pounds:

5 [A] =>   4,31
20 [B] => 23,19

5 [C] =>   3,84
10 [D] => 13,03

This way the user does not have to care about the sign, he just presses a unique key for each conversion.

Another idea:
The 11C has five label keys A...E. These could be used for up to five currency conversions. This time a positive input may convert to a currency and a negtive input back from that currency:

5 [A] => -4,31
[A] =>  5,00

How about that? Will you give it a try ?-)

Dieter
 « Next Oldest | Next Newest »

 Messages In This Thread (11C) Currency Converter - Gamo - 10-01-2018, 06:00 AM RE: (11C) Currency Converter - Dieter - 10-01-2018 11:58 AM RE: (11C) Currency Converter - Albert Chan - 10-01-2018, 12:49 PM RE: (11C) Currency Converter - Gamo - 10-01-2018, 01:00 PM RE: (11C) Currency Converter - Dieter - 10-01-2018, 04:02 PM RE: (11C) Currency Converter - Albert Chan - 10-01-2018, 04:37 PM RE: (11C) Currency Converter - Dieter - 10-01-2018, 06:05 PM RE: (11C) Currency Converter - Albert Chan - 10-01-2018, 06:28 PM RE: (11C) Currency Converter - Gamo - 10-02-2018, 01:53 AM

User(s) browsing this thread: 1 Guest(s)