/// Name: Afaf Nabeeha
/// Period: 7
/// Program Name: Counting with a For Loop
/// File Name: Counting.java
/// Date Finished: 1/29/2016 public class Counting
public class Counting
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 )
System.out.println( n + ". " + message );
// Removing n = n+1 will ensure that the loop runs on forever because n will never reach 5.
// n = 1 ensures that n has a value, and without it, the program wont work.
Picture of the output