Quote calculation using a scale
Posted: Mon Aug 31, 2009 8:21 am
Hi
I need to calculate a quote using a band/scale depending on number of people.
1 - 10 = 1.0 and 35
11 - 20 = 0.9 and 30
21 - 30 = 0.8 and 25
31 - 40 = 0.7 and 20
etc.
The user will inter the number of people and I will need to calculate an amount.
Example:
If the user enters 32, I will need to slot the people into the respective band i.e.
The first 10 will be: 10 x 1 x 35
The next 10 will be 10 x 0.9 x 30
The next 10 will be 10 x 0.8 x 25
and the remaining 2 will be 2 x 0.8 x 20
The value is the sum of each result.
Currently I would be using if and else statements to make this work and slot the values in the right band with the remainder in the last band.
Is there a better way of doing this such as arrays where it would fill up the first array 'pocket' with 10 and then slotting the remainder into the next 'pocket' etc.
This is hard to explain in a message so i hope I was clear.
Thanks
Robin
I need to calculate a quote using a band/scale depending on number of people.
1 - 10 = 1.0 and 35
11 - 20 = 0.9 and 30
21 - 30 = 0.8 and 25
31 - 40 = 0.7 and 20
etc.
The user will inter the number of people and I will need to calculate an amount.
Example:
If the user enters 32, I will need to slot the people into the respective band i.e.
The first 10 will be: 10 x 1 x 35
The next 10 will be 10 x 0.9 x 30
The next 10 will be 10 x 0.8 x 25
and the remaining 2 will be 2 x 0.8 x 20
The value is the sum of each result.
Currently I would be using if and else statements to make this work and slot the values in the right band with the remainder in the last band.
Is there a better way of doing this such as arrays where it would fill up the first array 'pocket' with 10 and then slotting the remainder into the next 'pocket' etc.
This is hard to explain in a message so i hope I was clear.
Thanks
Robin