View Single Post
Old 11-26-2010, 04:23 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
The loop declaration itself is fine, but probably not for what you are intending to do.

I perceive this as follows: an assignment is first graded giving the value of 'mark'. After it is graded, it is reduced by 5 marks/day until it hits a minimum of 20 (to me this hardly seems fair; I would reduce until 0, but I'm not the one giving marks ). To do this with a for loop, use multiple conditions:
PHP Code:
for (int m markdaysLate>= 20 && >= 0-= 5, ++d
So if 'mark' is 75, and it was late for fourteen days, logically:
PHP Code:
int mark 75;
int daysLate 14;
for (
int m markdaysLate>= 20 && >= 0-= 5, --d
m would be 20 and d would be 3 in the end (since only 11 days would be subtracted off).

This can also be calculated with just regular mathematics and conditions.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote