Jump to content

module, function

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
10 replies to this topic

#1
mike221

mike221

    Newbie

  • Members
  • PipPip
  • 11 posts
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

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
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.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
mike221

mike221

    Newbie

  • Members
  • PipPip
  • 11 posts
could someone please help? I will see a language later, first I need a help with a module and a function

#4
mike221

mike221

    Newbie

  • Members
  • PipPip
  • 11 posts
I mean first in theory, in algorithm sense. but later for example python, java, php...

#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
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.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#6
mike221

mike221

    Newbie

  • Members
  • PipPip
  • 11 posts
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

#7
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
It will depend on the language.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#8
mike221

mike221

    Newbie

  • Members
  • PipPip
  • 11 posts
sorry. Well; python

#9
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Moved to Python forum so those who know it's details can help.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#10
mike221

mike221

    Newbie

  • Members
  • PipPip
  • 11 posts
Could someone help?, please.

#11
Steve.L

Steve.L

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 444 posts
BeginnersGuide - PythonInfo Wiki

Learn the language. We're not your personal teachers, but we will help you if you get stuck on something specific.