Welcome to my Website!
///Name: Ilana Levy
///Period: 5
///Program Name: Counting with a While Loop
///File Name: countingWhile.java
///Date Finished: 9/21/2015
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, times;
System.out.print( "How many times? " );
times = keyboard.nextInt();
while ( n < times )
{
System.out.println( 10 * (n + 1 ) + ". " + message );
n++;
}
//1. the n++ is the counter. By constantly increasing itself by one every loop, the overall value of n increases and can reach 5, thereby triggering the while loop mechanism to stop. Else, the loop would continue indefinitely.
}
}