Quote:
Originally Posted by corecase
This is how i would do it:
Code:
int m = mark;
int d = daysLate;
if(m <= 20)
{
System.out.println("Mark is: " + m);
}
else
{
while(d >= 0 && m > 20)
{
m -= 5;
d--;
}
System.out.println("Mark is: " + m);
}
I think it's a bit easier to understand than using a for loop with two variables inside. Just my opinion though! Hope it helps! 
|
Your right, multiple variables and conditions in a for loop do tend to get complicated looking quite quickly, and neither approach has any additional overhead, so a simple if check followed by a while would be much easier to read than a single for loop.