Jump to content

Calculation problem in php


u0867587
 Share

Recommended Posts

This is a bit of a puzzle. Look at the sum and result below:

 

 $markTotal += ($session['Mark'] / 100 * $session['SessionWeight']);

 

 

Result on Browser with explanation to help you:

 

Module: CHI2550 - Modern Database Applications    35% (this is $markTotal)  ... This is where I want add the total mark for 100%

 

Session: AAB        100% (this is $session['Mark'])      10% (this is  $session['SessionWeight'])

 

Session: AAE      50% (this is $session['Mark'])    50%  (this is  $session['SessionWeight'])

 

All percentage marks above are just add ons.

 

 

As you can see the answer to the calculation above is right, the answer is 35 as it adds up the two session marks, divide by 100 and then times it by the total amount of the percentage.

 

But I want to include a total mark where except it is out of the total session percentage (60% for above example as one Session is 40% and the other is 20%), it is out of a 100% but I can not work as simple as that as in above example one session is worth more than other. The total mark out of 100% of the above example should be 65%, but how do I achieve this in my calculation. It is not as simple as dividing the $session['Mark'] because one session is worth more than the other. So the above example will have 2 marks: one mark out of total percentage of the Sessions which for the above example is 35% and second mark is out of the full 100% of the module which is 65%.

 

Thank you and any help is much appreciated

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

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.

 Share

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