Preview:
package sumsandaverage;
import java.util.Scanner;

public class SumsAndAverage {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
             Scanner input = new Scanner(System.in);
        System.out.print("Enter a number: ");
        int n = input.nextInt();

        int sum = 0;
        for (int i = 1; i <= n; i++) {
            System.out.print(i + " ");
            sum += i;
        }

        double average = (double) sum / n;

        System.out.println("\nSum: " + sum);
        System.out.println("Average: " + average);
    }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter