Assignment #63 Counting While
Code
/// Name: Lacey Reese
/// Period: 5
/// Program Name: CountingWhile
/// File Name: CountingWhile.java
/// Date Finished 12/10/2015
import java.util.Scanner;
public class CountingWhile
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
//removing the n++ made it so the message wouldnt stop. I said how many times I wanted the message to be printed, and I said 3, but it kept on going not knowing when to stop.
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 x = keyboard.nextInt();
int n = 0;
while ( n < x )
{
System.out.println( (10*n+10) + ". " + message );
n++;
}
}
}
Picture of the output
//