Assignment 88: Adding Values with a for loop

Code

    /// Name: Ryan McAteer
    /// Period: 5
    /// Program Name: Adding Values with a for Loop
    /// File Name: Assignment88.java
    /// Date Finished: 2/26/16
    
import java.util.Scanner;

public class Assignment88
{
	public static void main( String[] args )
	{
        Scanner keyboard = new Scanner(System.in);
        int number, y;
        y = 0;
        System.out.print("Number: ");
        number = keyboard.nextInt();
        System.out.println();
        for ( int x = 1; x <= number; x = x + 1 )
        {
            y = y + x;
            System.out.print( x + " " );
        }
        System.out.println("The sum is " + y + ".");
    }
}
    

Picture of the output

This Should Work