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