Write a method called sumRange that accepts two integer parameters that represent a range. Issue an error message and return zero if the second parameter is less than the first. Otherwise, the method should return the sum of the integers in that range (inclusive).
What will be an ideal response?
```
public int sumRange(int start, int end)
{
int sum = 0;
if (end < start)
System.out.println("ERROR: Invalid Rangeā);
else
for (int num = start; num <= end; num++)
sum += num;
return sum;
}
```
Computer Science & Information Technology
You might also like to view...
Class ________ allows you to represent an XML namespace.
a) XName b) XMLNamespace c) XNamespace d) XMLNS
Computer Science & Information Technology
When an object is passed as an argument to a method, what is passed into the method's parameter variable?
a. the class name b. the object's memory address c. the values for each field d. the method names
Computer Science & Information Technology