Assignment #88 and Adding Values with a For Loop

Code

    /// Name: Lauren Baird
    /// Period: 7
    /// Program Name: Adding Values with a For Loop
    /// File Name: AVForLoop.java
    /// Date Finished: 12/01/2015
    
    import java.util.Random;
    import java.util.Scanner;
    
    public class AVForLoop
    {
        public static void main( String[] args )
        {
            Random r = new Random();
            Scanner keyboard = new Scanner(System.in);
            
            int t = 0;
            int n;
            
            System.out.println();
            
            System.out.print( "Number: " );
            int c = keyboard.nextInt();
            System.out.println();
            
            for ( n = 1 ; n <= c ; n = n+1 )
            {
                System.out.print( n + " " );
                t = t + n;
            }
            
            
            
            System.out.println();
            System.out.println( "The sum is " + t );
            
            System.out.println();
        }
    }  
    

Picture of the output

Assignment #88