I want to do a module, a Function-type module.
I just want that module is right and then I may try
for example java, php, python - but that's not an issue now, I will see that later.
The module calculates the amount of the cash payment in connection with refundable sum of money.
And there must be a function, that will make a rounding with five penny accuracy.
function's call is f1 (y), where y is sum to be rounded off. A rounded off sum is obtained as a return value of the function.
This is very simple, I know, but I can't make this work, can you please help.
So this is how I have done it, but this isn't right.
MODULE ReturnMoney (y) (Items_sum, cash_payment)RETURNS money_back
money_back=f1 cash_payment - Items_sum ROUNDING??? HOW AND WHERE I PUT IT.....
ENDMODULE
This is easy in any language, but you really need to pick a language first. Note that not all languages support the concept of modules/functions.
could someone please help? I will see a language later, first I need a help with a module and a function
I mean first in theory, in algorithm sense. but later for example python, java, php...
You will probably need to multiply the value by 100, convert it to an integer, perform modulus division by 5, and then increase the original value by +2, +1, 0, -1, or -2 cents depending on that result.
thanks, But how I do that? I don't know how, I don't understand. And will I need another RETURN like this?;
MODULE ReturnMoney (y) (Items_sum, cash_payment)RETURNS money_back
RETURN money_back=f1 cash_payment - Items_sum
ENDMODULE
It will depend on the language.
sorry. Well; python
Moved to Python forum so those who know it's details can help.
Could someone help?, please.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks