breakdown by Percentages

itnchans

Registered User.
Local time
Today, 12:32
Joined
Nov 29, 2007
Messages
11
Good Mornig Everyone,

I'm currently working on a client project which involves taking a order or sandwiches and breaking in down into the following ratio :-

40% (Vegeterian) sandwiches
30% (Meat) sandwiches
30% (Fish) sandwiches

If there is a remainder then that is coverted to a vegiterian sandwich.

What the customer would do is order the sandwiches, then the office would prepare the order based on vegeterians, meat and fish.

From the above if someone orders 8 sandwiches, I get:-

40% of 8 = 3.2 - Veg
30% of 8 = 2.4 - Meat
30% of 8 = 2.4 - Fish

How can I work these percentages as whole number rather than decimals. or can someone guide me in terms of a access function to achieve results than I'm after.

What would be the best way to do this? Any suggestion?

Thanks in advance.
 
As he wants remainders to go to vegetarian then he is probably better off with Int to get the whole numbers for meat and Fish and then subtract their totals from the order to get the vegetarian.

Just my idea.

Brian
 
I think you shuld go with:

meat = round(0.3 * total)
fish = round(0.3 * total)
Vegeterian = total - meat - fish
 
you could also try int or fix function, which both round DOWN

so
int(somenumber) will round down

but
int(somenumber+0.999) will therefore always round up
 
you could also try int or fix function, which both round DOWN

so
int(somenumber) will round down

but
int(somenumber+0.999) will therefore always round up

I could have sworn that I suggested using Int, and to be pedantic, both it and Fix don't round, but remove the fraction part, the difference in them is the way they handle negative numbers, not relevent here.

Brian
 
brian - yes you did mention the Int function, reading the post again.
 

Users who are viewing this thread

Back
Top Bottom