Code:
// Determine new credit rating via inverse transform.
U = MTUniform (0);
// This can be made more efficient!!
int jmin;
jmin = (i >= 1 ? i-1 : 0);
for (j = jmin; j <= 8; j++) {
if (U <= P[i][j]) {
break;
}
if {j<i}
payout+=20,000,000
}
It's a pretty convoluted code. I am supposed to add a scenario where the bond rating drops to a new low and the agency pays out 20,000,000. I know that when j < i, we've that the bond rating when down. But the loop can run again twice and go from j>i back to j < i and we're at the same rating, but it went down so the program wants to payout 20million