How to resolve the algorithm Price fraction step by step in the 11l programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Price fraction step by step in the 11l programming language
Table of Contents
Problem Statement
A friend of mine runs a pharmacy. He has a specialized function in his Dispensary application which receives a decimal value of currency and replaces it to a standard value. This value is regulated by a government department.
Given a floating point value between 0.00 and 1.00, rescale according to the following table:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Price fraction step by step in the 11l programming language
Source code in the 11l programming language
F bisect_right(a, x)
V lo = 0
V hi = a.len
L lo < hi
V mid = (lo + hi) I/ 2
I x < a[mid]
hi = mid
E
lo = mid + 1
R lo
V _cin = [0.06, 0.11, 0.16, 0.21, 0.26, 0.31, 0.36, 0.41, 0.46, 0.51, 0.56, 0.61, 0.66, 0.71, 0.76, 0.81, 0.86, 0.91, 0.96, 1.01]
V _cout = [0.10, 0.18, 0.26, 0.32, 0.38, 0.44, 0.50, 0.54, 0.58, 0.62, 0.66, 0.70, 0.74, 0.78, 0.82, 0.86, 0.90, 0.94, 0.98, 1.00]
F pricerounder(pricein)
R :_cout[bisect_right(:_cin, pricein)]
L(i) 0..10
print(‘#.2 #.2’.format(i / 10, pricerounder(i / 10)))
You may also check:How to resolve the algorithm Arrays step by step in the Apex programming language
You may also check:How to resolve the algorithm Fivenum step by step in the R programming language
You may also check:How to resolve the algorithm Averages/Median step by step in the 11l programming language
You may also check:How to resolve the algorithm Price fraction step by step in the Ring programming language
You may also check:How to resolve the algorithm Compound data type step by step in the AmigaE programming language