How to resolve the algorithm Price fraction step by step in the jq programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Price fraction step by step in the jq 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 jq programming language
Source code in the jq programming language
def getScaleFactor:
["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"] as $values
| $values[ (. * 100 - 1) / 5 | floor ] ;
def test:
(range(0;10) | "0.0\(.) -> \( 0.01 * . | getScaleFactor)"),
(range(10;100) | "0.\(.) -> \( 0.01 * . | getScaleFactor)");
test
You may also check:How to resolve the algorithm Sleeping Beauty problem step by step in the Ruby programming language
You may also check:How to resolve the algorithm Bulls and cows step by step in the BBC BASIC programming language
You may also check:How to resolve the algorithm Catalan numbers step by step in the D programming language
You may also check:How to resolve the algorithm Kronecker product step by step in the ooRexx programming language
You may also check:How to resolve the algorithm Terminal control/Coloured text step by step in the PowerShell programming language