(12C Platinum) Successive Discounts - Printable Version +- HP Forums ( https://www.hpmuseum.org/forum)+-- Forum: HP Software Libraries ( /forum-10.html)+--- Forum: General Software Library ( /forum-13.html)+--- Thread: (12C Platinum) Successive Discounts ( /thread-12007.html) |

(12C Platinum) Successive Discounts - Gamo - 12-22-2018 05:07 AM
Successive discount is the discount offered on the discount. It is similar to compound interest (interest on interest). A company many offer two trade discount, 20% and 5%. One customer may be entitled to a 20% discount and another will get 5%, depending on status (jobber, wholesaler, retailer, etc.), and a third customer of different status will receive 20% and 5%. The two discounts cannot be simply added together (20% + 5% = 25%) is inapplicable. You have to use the following formula: X = Price Y = Discount % Z = Discount % Selling Price = X - [Y + Z - (Y*Z / 100)] * X --------------------------------------------------- Procedure: Price [R/S] Discount % [R/S] Discount % [R/S] Answer display Total Discount% briefly then Selling Price. ***If you have the third discount.*** RCL 3 [R/S] RCL 1 [R/S] Discount % [R/S] Answer display Total Discount% briefly then Selling Price. ---------------------------------------------------------------- Example: FIX 2 If original price is $135 and the trade discount are 20% and 15% What is the Selling Price. 135 [R/S] display 135.00 20 [R/S] display 20.00 15 [R/S] display briefly 32.00 then 91.80 Answer: Total Discount Rate is 32% Selling Price is $91.80 ------------------------------------------------ The successive discount on a product in a store is giving as 5%, 10% and 15%. The store price of the product is $1000. Then calculate overall discount and selling price of the product. 1000 [R/S] display 1000.00 5 [R/S] display 5.00 10 [R/S] display briefly 14.50 then 855.00 Answer for Total Discount % of the first two discount is 14.5% and Selling Price is $855.00 To add the third discount. RCL 3 [R/S] display 1000.00 RCL 1 [R/S] display 14.50 15 [R/S] display briefly 27.33 then 726.75 Answer: All Total of Three discount % is 27.33% Selling price is $726.75 -------------------------------------------------- Program: ALG mode Code:
Program: RPN Code:
Gamo RE: (12C Platinum) Successive Discounts - Dieter - 12-22-2018 09:07 AM
(12-22-2018 05:07 AM)Gamo Wrote: The two discounts cannot be simply added together That's a quite complicated way of calculating accumulated discounts. Edit: and most important, it's wrong. The term within the square brackets is the total discount in percent, so there is a factor 100 missing. Doing it with discount factors is easier and not limited to just two successive discounts. Simply calculate 1 – d/100 for each discount rate d and multiply these factors. For 5%, 10% and 15% this yields 0,95 · 0,90 · 0,85 = 0,72675. Multiply the original price by this and get the discounted price. Also 1 minus that factor is the total discount rate, i.e. 0,27325 or 27,325%. The last program in this post uses this approach. (12-22-2018 05:07 AM)Gamo Wrote: The successive discount on a product in a store is giving as Waaaay too complicated. ;-) You don't even need a program for this: Enter original price [ENTER] [ENTER] [ENTER] For each discount: Enter discout rate [%] [–] and get the dicounted price Finally press [Δ%] to see the total discount in percent. Example: 1000 [ENTER] [ENTER] [ENTER] 5 [%] [–] => 950,00 10 [%] [–] => 855,00 15 [%] [–] => 726,75 [Δ%] => –27,33 total discount in % After this you can press [%] to see the total discounted amount. Another [+] returns to the discounted price. [%] => –273,25 (total discount in € or $ or whatever) [+] => 726,75 (the discounted price again) If you really want to use a program, what about this one (RPN mode): Code: `01 STO 0` It can even be done without any data registers: Code: `01 ENTER` As usual, reset the program with f [PRGM] first. Enter initial price [R/S] Enter as many discounts as you want, each followed by [R/S] The discounted price is displayed After the last discount enter 0 [R/S] The total discount in percent is displayed Your example: 1000 [R/S] => 1000,00 5 [R/S] => 950,00 (price after first discount) 10 [R/S] => 855,00 (price after second discount) 15 [R/S] => 726,75 (price after third discount) 0 [R(S] => –27,33 (total discount is 27,33%) Here is another version that also displays the intermediate discount percentages. Code: `01 STO 0` Same example: f [PRGM] 1000 [R/S] => "0,00" 1000,00 5 [R/S] => "5,00" 950,00 10 [R/S] => "14,50" 855,00 15 [R/S] => "27,33" 726,75 When a result is displayed you may press [X<>Y] to show the accumulated discount rate and the disounted price again. [X<>Y] 27,33 [X<>Y] 726,75 Dieter Note: this post has been edited several times to add more programs and some other ideas which I had after I posted the original message. ;-) RE: (12C Platinum) Successive Discounts - Werner - 12-23-2018 09:11 AM
(1 + i%/100)*(1+j%/100) = 1 + (i%+j%+i%*j%/100)/100 So, In: Y: i% X: j% Out X: i%+j%+i%*j%/100 Then Code: ` %` Cheers, Werner RE: (12C Platinum) Successive Discounts - Dieter - 12-23-2018 09:33 AM
(12-23-2018 09:11 AM)Werner Wrote: (1 + i%/100)*(1+j%/100) = 1 + (i%+j%+i%*j%/100)/100 Yes, that's the term in square brackets in Gamo's formula. Except the sign which has to be negative here – we are calculating discounts. Using your suggestion, the complete program can be as short as this: Code: `01 %` 1000 [ENTER] 5 [ENTER] 10 [R/S] => 855,00 (discounted price) [Δ%] => –14,50 (total discount in %) But it still works only for two discount rates. Dieter RE: (12C Platinum) Successive Discounts - Gamo - 12-23-2018 03:05 PM
Thanks Dieter The manual calculations is a good one. Easy to remember those steps too. Gamo RE: (12C Platinum) Successive Discounts - SlideRule - 12-23-2018 03:13 PM
Given three successive discounts as i%, j%, & k%, the total discount is … Δ = i + j - (ij/100)% Σ = Δ + k - (Δk/100)% … calculate the initial compound discount, then substitute this result for the first term, with the third discount as the second term in the initial compound discount formula for the TOTAL discount {recursive loop}. BEST! SlideRule RE: (12C Platinum) Successive Discounts - Dieter - 12-23-2018 06:16 PM
(12-23-2018 03:13 PM)SlideRule Wrote: … calculate the initial compound discount, then substitute this result for the first term, with the third discount as the second term in the initial compound discount formula for the TOTAL discount {recursive loop}. Not recursive, but iterative. For instance this way: Code: `01 ENTER` Enter the inital price [R/S], then the first, second, third, ... percentage [R/S]. 1000 [R/S] => 0,00 no discount yet 5 [R/S] => 5,00 5% discount so far 10 [R/S] => 14,50 now it's 14,5% 15 [R/S] => 27,33 and finally 27,3% [%] => 273,25 discount [–] => 726,75 final price Dieter RE: (12C Platinum) Successive Discounts - SlideRule - 12-23-2018 07:45 PM
(12-23-2018 06:16 PM)Dieter Wrote: Not recursive, but iterative. OK! re·cur·sive /rə'kərsiv/ characterized by recurrence or repetition. MATHEMATICS relating to or involving the repeated application of a rule, definition, or procedure to successive results. it·er·a·tive /'idə,rādiv/ relating to or involving iteration, especially of a mathematical or computational process. it·er·a·tion /idə'rāSH(ə)n/ repetition of a mathematical or computational procedure applied to the result of a previous application BEST! SlideRule RE: (12C Platinum) Successive Discounts - Gamo - 12-24-2018 06:32 AM
The meaning between Iteration and Recursion is very interesting to find out. So I did some searching around the web and here what they said the different and explanation. ---------------------------------------------- Iteration and Recursion are key Computer Science techniques used in creating algorithms and developing software. In simple terms, an iterative function is one that loops to repeat some part of the code, and a recursive function is one that calls itself again to repeat the code. Using a simple for loop to display the numbers from one to ten is an iterative process. Examples of simple recursive processes aren't easy to find, but creating a school timetable by rearranging the lessons, or solving the Eight Queens Problem are common examples. ---------------------------------------------- The old recruiting practice says, "Never hire a developer who computes the factorial using Recursion". Recursion is often used without considering alternatives before using it. Though it is true that recursive solution is often more elegant and easier to spot than the iterative solution, one should take care not to abuse it. Complex Recursion that is hard to understand should probably be considered a "bad smell" in the code and a good candidate to be replaced with Iteration (usually in combination with some other Refactorings). Moreover, iterative solutions are usually more efficient than recursive solutions as they don't incur the overhead of the multiple method calls. We use Recursion when we have to perform a complex task that can be broken into the several subtasks. Recursion is implemented as a method that calls itself to solve subtasks. During the recursive call the values of the local fields of the method are placed on the method stack until the subtask performed by a recursive call is completed. Thus, whenever recursive method is called, local fields are put on the method stack and used again after the recursive call is completed. The general approach to Refactoring could probably be to implement the alternative Stack that "simulates" the method stack where the local fields could be placed (the java.util.Stack class is a good candidate for this job). -------------------------------------------------- Gamo RE: (12C Platinum) Successive Discounts - Thomas Klemm - 12-24-2018 11:25 AM
(12-24-2018 06:32 AM)Gamo Wrote: … a recursive function is one that calls itself again to repeat the code. That might also be a function ping calling a function pong and vice versa. Or involve even more functions. (…) Quote:The old recruiting practice says, "Never hire a developer who computes the factorial using Recursion". These times are fortunately over. (…) Quote:During the recursive call the values of the local fields of the method are placed on the method stack until the subtask performed by a recursive call is completed. Cf. tail call and continuation-passing style. (…) Quote:(the java.util.Stack class is a good candidate for this job). You don't want future generations hate you, do you? Cheers Thomas RE: (12C Platinum) Successive Discounts - Albert Chan - 12-24-2018 12:52 PM
(12-24-2018 11:25 AM)Thomas Klemm Wrote:(12-24-2018 06:32 AM)Gamo Wrote: … a recursive function is one that calls itself again to repeat the code. My primepi.lua does the ping/pong/more way ... Usage: lua primepi.lua 1e12 ==> 37607 912018 https://primes.utm.edu/howmany.html |