Assignemnt 88 and Adding Values With A For Loop

Code

    /// Name: Xinting Chen
    /// Period: 7
    /// Program Name: Adding Values With A For Loop
    /// File Name: AddingValuesWithAForLoop.java
    /// Date Finished: 3/1/2016
  
    import java.util.Scanner;
  
     public class AddingValuesWithAForLoop
      {
          public static void main( String[] args )
          {
              Scanner keyboard = new Scanner(System.in);
              int number, total;
              total = 0;
              
              System.out.print( "Number: ");
              number= keyboard.nextInt();
              
              for ( int x=1; x<= number; x++)
              {
                  System.out.println( x + " ");
                  total = total + x;
              }
              
              System.out.println( "The Sum Is "+ total );
          }
     }

    

Picture of the output

Assignment 88