#78 and Counting with a For Loop

Code

  /// Name: Josh Bautista
  /// Period: 6
  /// Program Name: Countint with a for loop
  /// File Name: Countingfor.java
  /// Date Finished: 2/26/2015
  
  import java.util.Scanner;

public class CountingFor
{
    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();

        for ( int n = 2 ; n <= 10 ; n = n+2 )
        // n = n+1 tells code how many times it must happen
        // n = 1 states n as a valuable of 1 allowing for code to repeat due to n <= 5
        {
            System.out.println( n + ". " + message );
        }

    }
}
    

Picture of the output

Assignment 4