Assignemnt #88

Code

    Name: Mahima Choudhary
    Period: 6
    Project Name: AVWAFL
    File Name: AVWAFL.java
    Date: 1/11/2015
    
import java.util.InputMismatchException;
import java.util.Scanner;

public class AVWAFL
{

	public static void main(String[] args)
	{
		Scanner keyboard = new Scanner(System.in);
		int num = 0;
		int total = 0;

		try {
			System.out.print("Number: ");
			num = keyboard.nextInt();
		} catch (InputMismatchException var5) {
			System.out.println("WRONG INPUT!!!");
		}

		System.out.println();

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

		System.out.println();
		System.out.println("The sum is " + total);
	}
}

    

Picture of the output

Assignment 85