// This program prompts the user for a maximum value to use and // reports the sum of the integers from 1 to that maximum. import java.util.*; public class CumulativeSum { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("give me an int-> "); int n = console.nextInt(); int answer = findSum(n); System.out.println("sum = " + answer); } // returns the sum of the integers 1 through max public static int findSum(int max) { int sum = 0; for (int i = 1; i <= max; i++) { sum = sum + i; } return sum; } }