Scanner sumCopy and paste the following code into jGrasp.
public class SumNumbers {
public static void main(String[] args) {
int low = 1;
int high = 1000;
int sum = 0;
for (int i = low; i <= high; i++) {
sum += i;
}
System.out.println("sum = " + sum);
}
}
continued on next slide...
Scanner sum
Modify the code to use a Scanner to prompt the user for the values of low and high. Below is a sample execution in which the user asks for the same values as in the original program (1 through 1000):
low? 1 high? 1000 sum = 500500
Below is an execution with different values for low and high:
low? 300 high? 5297 sum = 13986903
You should exactly reproduce this format.