Assignemnt #63: Counting with While Loop
Code
///Name: Cassie
///Period: 6
///Program Name: Counting with a While Loop
///File Name: counting.java
///Date Finished: 12/8/15
import java.util.Scanner;
class counting
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int n = 0, rep;
System.out.println( "Type in a message, and I'll display it ten times." );
System.out.print( "Message: " );
String message = keyboard.nextLine();
System.out.print( "How many times? " );
rep = keyboard.nextInt();
while ( n < rep )
{
System.out.println( (n*10) + ". " + message );
n++;
}
}
}
Picture of the output