045 - Accumulator Method Practice 1

    045 - Accumulator Method Practice 1

    045 - Accumulator Method Practice 1

    Write a method header on line two with the following specs: Returns: an integer Name: sumToX Parameters: an integer called "x" Purpose: calculate the sum of the integers from 1 to x (including x) Examples: sumToX(5) ==> 15 sumToX(7) ==> 28 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import java.util.*; class Main { public static int sumToX(int x) { int sum=0; for(int i=1;i