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