Assignemnt #63 Counting with a While Loop

Code

    Name: Iaroslav Titov
    Period: 7
    Project Name: CountingWhile
    File Name: CountingWhile.java
    Date: 11/10/2015
    
import java.util.Scanner;
import java.util.InputMismatchException;

public class CountingWhile
{
	public static void main( String[] args )
	{
		Scanner keyboard = new Scanner(System.in);

		System.out.println( "Type in a message, and I'll display it several times." );
		System.out.print("Message: ");
		String message = keyboard.nextLine();

		int times = 0;

		try
		{
			System.out.print("\nHow many times?");
			times = keyboard.nextInt();
		}
		catch (InputMismatchException e)
		{
			System.out.println( "WRONG INPUT!!!" );
		}


		int n = 0;
		while ( n < times )
		{
			System.out.println( (n+1)*10 + ". " + message );
			n++;
		}

	}
}

// n++ adds 1 to the counter n, so program will
    

Picture of the output

Assignment 60