Assignemnt #84 Add With A For Loop

Code

/// Name:JJ Deng
/// Period: 6
/// Program Name: Adding Values With A For Loop
/// File Name: AddWith4Loop.java
/// Date Finished: 2/23/2016
  
    import java.util.Scanner;
  
     public class AddWith4Loop
      {
          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