I'm required to set a max value for a variable to 100:
double area = length * width;
if (area > 100) { //set parameters for area
area = 100;
}
How can I code this in a way that works and doesn't require the use of 'if statement'?
double area = Math.min(length * width, 100);
if statements because you haven't learned them yet, I cannot guarantee you'd be allowed to use this either for the same reason.You could try using Math.min, although I personally think it's less clear.
area = Math.min(area, 100);
ifstatement?