How to resolve the algorithm Price fraction step by step in the M2000 Interpreter programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Price fraction step by step in the M2000 Interpreter 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 M2000 Interpreter programming language

Source code in the m2000 programming language

Module PriceFraction {
	Currency i
	Print $("0.00"),
	for i=0@ to 1@ step .10@
		Print i, @PriceFraction(i)
	next
	Print $(""),
	
	function PriceFraction(price as currency)
	    select case price
	        case < 0
	            = price
	        case < .06
	            = .1
	        case < .11
	            = .18
	        case < .16
	            = .26
	        case < .21
	            = .32
	        case < .26
	            = .38
	        case < .31
	            = .44
	        case < .36
	            = .5
	        case < .41
	            = .54
	        case < .46
	            = .58
	        case < .51
	            = .62
	        case < .56
	            = .66
	        case < .61
	            = .7
	        case < .66
	            = .74
	        case < .71
	            = .78
	        case < .76
	            = .82
	        case < .81
	            = .86
	        case < .86
	            = .9
	        case < .91
	            = .94
	        case < .96
	            = .98
	        case < 1.01
	            = 1!
	        case else
	            = price
	    end select
	end function
}
PriceFraction

  

You may also check:How to resolve the algorithm Call a function step by step in the Axe programming language
You may also check:How to resolve the algorithm Factors of an integer step by step in the C programming language
You may also check:How to resolve the algorithm CRC-32 step by step in the PHP programming language
You may also check:How to resolve the algorithm Cartesian product of two or more lists step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Sierpinski carpet step by step in the AutoHotkey programming language