public class WhileLoops
{
	public static void main(String[] args)
	{
		//While loop to count from 1 to 10
		int cnt=1;

		while (cnt<=10)
		{
			System.out.println("cnt = "+cnt); //Print out the loop iteration based on the "cnt" int variable.
			cnt++; //Increment the counter variable by 1
		}

		//------------------------------------------->

		System.out.println(); //Print blank line to separate the output...

		//Do While Loop to count down from 10 to 1
		cnt=10;

		do
		{
			System.out.println("cnt = "+cnt);
			cnt--; //Decrement the counter variable by 1
		} while (cnt>0);

		//------------------------------------------->


		//------------------------------------------->

		System.out.println(); //Print blank line to separate the output...

		//While loop to count from 1 to 10, but will break at 5...

		cnt=1;

		while (cnt<=10)
		{
			System.out.println("cnt = "+cnt);

			if (cnt==5)
			{
				System.out.println("Stopping the loop at cnt = "+cnt);
				break; //This will cause the loop to stop and
				       //JUMP to the first line immediately after the loop...
			}

			cnt++; //Increment the counter variable by 1
		}

		System.out.println("We are now out of the for loop...");

		//------------------------------------------->
	}
}
