Assignment 87

Code

///Matthew Hughs
///5th period
///Add.java
///4/13/2016

import java.util.Scanner;

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

Picture of the output

Countingfor