NachoF Posted June 17, 2008 Share Posted June 17, 2008 I was trying (long explanation as to why) to find out all the possible combinations to get below 9.5 but above 8.5 as the final grade of a course that consists on three tests, two quizes and points that you get only if you get 10 points or more(20 is the highest possible grade )on each test (0.5, 0.5 and 1 extra point respectively).... I tried this very simple algorithm but for odd reason the highest grade I get is 18, not 20..... it appears to not be adding the extra 0.5s and 1... any help appreciated. <?php for($i=0;$i<=20;$i++) { $definitiva=0; for ($j=0;$j<=20;$j++) { $definitiva=0; for ($k=0;$k<=20;$k++) { $definitiva=0; for ($l=0;$l<=20;$l++) { $definitiva=0; for ($m=0;$m<=20;$m++) { $definitiva=0; $definitiva=($i/4)+($j/4)+($k*3/10)+($l/20)+($m/20); if($i>=10) { $definitva+=0.5; } if($j>=10) { $definitva+=0.5; } if($k>=10) { $definitva++; } if($definitiva>17)//($definitiva>=8.5)&&($definitiva<9.5)) { echo "Has podido sacar " . $i . " , " . $j. " , " . $k . " en los parciales y ". $l ." , " . $m . " en los talleres y te daba ".$definitiva ."<br>"; } } } } } } ?> Link to comment https://forums.phpfreaks.com/topic/110524-weird-result/ Share on other sites More sharing options...
NachoF Posted June 17, 2008 Author Share Posted June 17, 2008 Nevermind.... i figured it out...definitiva was misspeled under the conditions to add 0.5 or 1 Link to comment https://forums.phpfreaks.com/topic/110524-weird-result/#findComment-567017 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.