Assignment #88
Code
///Name: Cody Swain
///Period: 6
///Project Name: AddingValues
///File Name: AddingValues.java
///Date: 1/15/16
import java.util.Scanner;
public class AddingValues
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int m, sum = 0;
System.out.print( "Enter a number: ");
m = keyboard.nextInt();
for ( int n = 1; n <= m ; n++ ){
System.out.print( " " + n );
sum = sum + n;
}
System.out.println();
System.out.println();
System.out.println( " The sum is " + sum );
}
}
Picture of the output