Assignment #63 Counting with a while loop
Code
/// Name: DeeJay Cerezo
/// Period: 7
/// Program Name: Counting Stuff
/// File Name: Counting.java
/// Date Finished: 12/8/2015
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." );
System.out.println( "How many times do you want to display?" );
System.out.print( "Number: " );
number = keyboard.nextInt();
System.out.print( "Message: " );
String message = keyboard.nextLine();
int n = 0, x = 0, number;
while ( n < number )
{
System.out.println( (n+1) + ". " + message );
n++;
}
}
}
Picture of the output