While Loops #63 (Got your back!)
Code
/// Name: Amir Salehi
/// Period: 7
/// Program Name:Counting While
/// File Name:CountingWhile.java
/// Date Finished: 12/7/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." );
System.out.print( "Message: " );
String message = keyboard.nextLine();
System.out.println( "How many times?");
int x = keyboard.nextInt();
int n = 0;
while ( n < x )
{
System.out.println( (n+1) + ". " + message );
n++;
//n++, adds the amounts of strings.
}
}
}
Picture(s) of the output