Assignment #119 and Adding Values with a for loop

Code

        /// Name: Trent Lane
    /// Period: 6
    /// Program Name: Adding Values with a For Loop
    /// Date Finished: 2/26/2016
    
    import java.util.Scanner;

    public class AddValFor
    {
        public static void main(String[] args)
        {
            Scanner kb = new Scanner(System.in);
            
            int maxNum;
            int sumNum = 0;
            
            System.out.print("Number: ");
            maxNum = kb.nextInt();
            
            System.out.println();
            
            for ( int i = 1; i <= maxNum; i++ )
            {
                System.out.print(i + " ");
                sumNum = sumNum + i;
            }
            
            System.out.println("\nThe sum is " + sumNum + ".");
        }
    }

 

Picture of the output

Assignment 71