For loops #88 (Just keep adding)
Code
/// Name: Amir Salehi
/// Period: 7
/// Program Name:AVwaFL
/// File Name:AVwaFL.java
/// Date Finished: 2/17/2016
import java.util.Scanner;
public class AVwaFL
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int t = 0;
System.out.println();
System.out.print( "Number: " );
int c = keyboard.nextInt();
System.out.println();
for ( int n = 1 ; n <= c ; n = n+1 )
{
System.out.print( n + " " );
t = t + n;
}
System.out.println();
System.out.println( "The sum is " + t );
System.out.println();
}
}
Picture(s) of the output