Assignment #63: Counting with a While Loop

Code

/// Name: Kiran O'Farrell
/// Program Name: Counting with a While Loop
/// File Name: CountingWhile.java
/// Date Completed: 1/12/15

import java.util.Scanner;

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 five times." );
		System.out.print( "Message: " );
		String message = keyboard.nextLine();

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

	}
    
}
    

Picture of the output

Notes