import cs1.Keyboard; /** Calculate the sum of integers from i to j. @author Greg Vogl last modified 2003-09-22 */ public class Sumij { /** Calculate the sum of integers from i to j. */ public static void main (String[] args) { // get input System.out.println("This program calculates the sum of integers from i to j."); System.out.println("Enter the first integer i and press Enter."); int i = Keyboard.readInt(); System.out.println("Enter the second integer j and press Enter."); int j = Keyboard.readInt(); // calculate statistics int sum = 0; for (int k = i; k <= j; k++) sum += k; // output results System.out.println("The sum of all integers from " + i + " through " + j + " is " + sum); } }