Assignemnt 63 and Counting With a While Loop
Code
/// Name: Xinting Chen
/// Period: 7
/// Program Name: Counting With a While Loop
/// File Name: CountingWhile.java
/// Date Finished: 12/4/2015
import java.util.Scanner;
public class CountingWhile
{
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