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