Assignemnt #63 and Counting With a While Loop
Code
/// Name: Brian Phillips
/// Period: 5
/// Program name: CountingWhile.java
/// File Name: Counting With a While Loop
/// Date Finished: 12/18/2015
import java.util.Scanner;
public class CountingWhile
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
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?" );
int Number = keyboard.nextInt();
//n++ adds plus 1 to the n if it is not there the message will repeat infinately
int n = 0;
while ( n < Number )
{
System.out.println( (n+10)*(10) + ". " + message );
n++;
}
}
}
Picture of the output