import java.util.Scanner; public class ForLoopAdding { public static void main( String[] args ) { Scanner keyboard = new Scanner(System.in); int sum = 0; System.out.print("Number: "); int fin = keyboard.nextInt(); System.out.println(""); for ( int i=1; i <= fin; i++ ) { System.out.print(i+ " "); sum = sum + i; } System.out.println("\nThe sum is " +sum+ "."); } }