Jump to content

Calculation problem in php


u0867587

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
https://forums.phpfreaks.com/topic/250411-calculation-problem-in-php/
Share on other sites

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.