class SumPractice { // Returns the sum of the first N odd // numbers. public static int sumOfOdds(int n) { int odd = 1; int sum = 0; while (n > 0) { sum = sum + odd; odd = odd + 2; n--; } return sum; } public static void main(String[] args) { int n = 10; int sum = sumOfOdds(n); System.out.println("The sum of the first " + n + " odd numbers is " + sum + "."); } }