Assignment #63
Code
/// Name: Jonathan Stine
/// Period: 5
/// Program Name: Counting with a While Loop
/// File Name: Counting.java
/// Date Finished: 1/19/16
import java.util.Scanner;
public class Counting
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
System.out.println( "Type in a message, and I'll display it however many times you want." );
System.out.print( "Message: " );
String message = keyboard.nextLine();
System.out.print( "How many times? " );
int k = keyboard.nextInt();
int n = 0;
while ( n < k )
{
System.out.println( (10*n+10) + ". " + message );
n++;
}
}
}
Code Output