java

profileNoraT
CheckstyleLab.java

// COURSE: CSCI1620. // TERM: Spring 2021 // // NAME: // RESOURCES: This class /** * Lab to practice Checkstyle formatting. * @author */ public class CheckstyleLab { /** * final static means this variable is a constant and only associates with the class itself. */ private static final int ARR_SIZE = 10; /** * Main method which calculates the sum of the squares of the integers 1 to 10 inclusive. * @param args Command line arguments (Unused) */ public static void main(String[] args) { int[] squares = new int[ARR_SIZE]; for (int i = 0; i < 10; i++) { squares[i] = (int) Math.pow(i, 2); System.out.printf("Square of %d is %d\n", i + 1, squares[i]); } System.out.printf("The Sum of the Squares is %d!\n\n", sumArray(squares)); } /** *This method returns the sum of the values in the arr parameter or zero when arr is null. *@return {number} sum *@param arr is the array needed */ public static int sumArray(int[] arr) { int sum = 0; for (int i = 1; i <= arr.length; i++) { sum += arr[i]; } return sum; } }