Jump to content

[SOLVED] Averaging a number over days with some days being weighted more than others


86Stang

Recommended Posts

The following is an example of a problem that I must figure out and the math itself has stumped me...

 

I have to take a number inputted from the user, say 50,000, and divide it by the number of days that they also enter with a weekend day only being worth 32.5% of a weekday.  I'm already calculating how many weekdays and weekend days there are in the date range given - I just need the basic math equation.

 

Anyone wanna help out the mathematically challenged? :)

simple, assuming i've understood your question correctly (which is probably a dangerous assumption).  multiply the weekend days by 0.325 to get their weekday-equivalence, add the weekdays and weekday equivalents together, THEN divide:

 

$weekdays = 56;
$weekend_days = 14;
$weekday_equivalence = $weekend_days * 0.325;
$salary = 50000;

$per_day = round($salary / ($weekdays + $weekday_equivalence), 2);

 

the variable names are just assuming you're calculating the daily income from salary.  i've also not rounded the weekday equivalence since i imagine it will make a difference.

 

EDIT:  note that here i've added in the actual division.  not a significant difference, you could do so beforehand.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.