C
cylurian
Hello everyone. I create a lot of math questions with PERL and
display them in html. One item that kills me is using negative signs,
especially for displaying on html. Question is what is the best
efficient way to account for positive and negative (addition and
subtraction) signs when displaying in html? I write many conditional
statements so I can account for the sign (operations). For example,
lets say I have a quadratic: ax^2 + bc + c = 0
And I want a, b and c to be random from -9 to -1 and 1 to 9. When I
print the problem, I have to all the cases for displaying in html.
If (($a >= 1)&&($b >= 1)&&($c >= 1) {
print "$a x<sup>2</sup> + $b x + $c = 0";
}elsif (($a >= 1)&&($b <= 1)&&($c >= 1)) {
print "$a x<sup>2</sup> $b x + $c = 0";
}..... keeps going until I cover all possible combinations with negative
and positive signs. Any suggestions on being more efficient?
display them in html. One item that kills me is using negative signs,
especially for displaying on html. Question is what is the best
efficient way to account for positive and negative (addition and
subtraction) signs when displaying in html? I write many conditional
statements so I can account for the sign (operations). For example,
lets say I have a quadratic: ax^2 + bc + c = 0
And I want a, b and c to be random from -9 to -1 and 1 to 9. When I
print the problem, I have to all the cases for displaying in html.
If (($a >= 1)&&($b >= 1)&&($c >= 1) {
print "$a x<sup>2</sup> + $b x + $c = 0";
}elsif (($a >= 1)&&($b <= 1)&&($c >= 1)) {
print "$a x<sup>2</sup> $b x + $c = 0";
}..... keeps going until I cover all possible combinations with negative
and positive signs. Any suggestions on being more efficient?