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? :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.