Assignemnt #88 and Adding Value In For Loop

Code

    ///Name: Daniel Tiffany-Appleton
    ///Period: 7
    ///Program Name: Adding Value In For Loop
    ///File Name: AddingValueInForLoop
    ///Date Finished: 2/8/16
    
    import java.util.Scanner;
    
    public class AddingValueInForLoop
    {
        public static void main( String[] args )
        {
            
            Scanner keyboard = new Scanner(System.in);
            
            int numberTo, total, amount; 
            
            System.out.print( "Number: " );
            numberTo = keyboard.nextInt();
            System.out.println( " " );
            
            amount = 0;
            total = 0;
            
            for ( int i = 1 ; i <= numberTo ; i++ )
            {
                amount = total;
                System.out.print( i + " " ); 
                total = amount + i;
            }
            
            System.out.println( "\nThe sum is " + total + "." );
            
        }
    }


    

Picture of the output

Assignment 69