Assignemnt #63 Counting with a While Loop
Code
//Tyler Hart
//period 5
//Counting with a While Loop
//CountingWhile.java
//11/18/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();
System.out.println( "How many times?" );
int n2 = keyboard.nextInt();
int n = 0;
while ( n < n2 )
{
System.out.println( (n+1) + "0. " + message );
n++;
//incresses n by one
}
}
}
Picture of the output