Assignment 63: Counting With a While Loop
Code
/// Name: Ryan McAteer
/// Period: 5
/// Program Name: Counting w/ While Loops
/// File Name: Assignment63.java
/// Date Finished: 12/2/15
import java.util.Scanner;
public class Assignment63
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
System.out.println( "Type in a message, and I'll display it n times." );
System.out.print( "Message: " );
String message = keyboard.nextLine();
System.out.println("How many times would you like me to repeat it?");
System.out.print("> ");
int times = keyboard.nextInt();
int n = 0;
while ( n < times )
{
System.out.println( (10*n + 10) + ". " + message );
n++;
}
//It adds one to the previous number//
}
}
Picture of the output